Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-09-07 21:32:52 +02:00
Commit
21a6852593
44
all/pom.xml
44
all/pom.xml
@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>viabackwards-parent</artifactId>
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
<groupId>nl.matsv</groupId>
|
<groupId>nl.matsv</groupId>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -44,6 +44,34 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
<minimizeJar>false</minimizeJar>
|
<minimizeJar>false</minimizeJar>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.github.steveice10.opennbt</pattern>
|
||||||
|
<shadedPattern>us.myles.viaversion.libs.opennbt</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>com.google.gson</pattern>
|
||||||
|
<shadedPattern>us.myles.viaversion.libs.gson</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>javassist</pattern>
|
||||||
|
<shadedPattern>us.myles.viaversion.libs.javassist</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.yaml.snakeyaml</pattern>
|
||||||
|
<shadedPattern>us.myles.viaversion.libs.snakeyaml</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>net.md_5.bungee</pattern>
|
||||||
|
<shadedPattern>us.myles.viaversion.libs.bungeecordchat</shadedPattern>
|
||||||
|
<includes>
|
||||||
|
<include>net.md_5.bungee.api.chat.**</include>
|
||||||
|
<include>net.md_5.bungee.api.ChatColor</include>
|
||||||
|
<include>net.md_5.bungee.api.ChatMessageType</include>
|
||||||
|
<include>net.md_5.bungee.chat.**</include>
|
||||||
|
</includes>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
@ -76,10 +104,22 @@
|
|||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<artifactId>viabackwards-fabric</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>nl.matsv</groupId>
|
<groupId>nl.matsv</groupId>
|
||||||
<artifactId>viabackwards-sponge</artifactId>
|
<artifactId>viabackwards-sponge</artifactId>
|
||||||
<version>${project.parent.version}</version>
|
<version>${project.parent.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<artifactId>viabackwards-velocity</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>viabackwards-parent</artifactId>
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
<groupId>nl.matsv</groupId>
|
<groupId>nl.matsv</groupId>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: ViaBackwards
|
name: ViaBackwards
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
description: Allows 1.9.x on a 1.10 Spigot server
|
description: Allow older Minecraft versions to connect to a newer server version.
|
||||||
main: nl.matsv.viabackwards.BukkitPlugin
|
main: nl.matsv.viabackwards.BukkitPlugin
|
||||||
|
|
||||||
authors: [Matsv]
|
authors: [Matsv]
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>viabackwards-parent</artifactId>
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
<groupId>nl.matsv</groupId>
|
<groupId>nl.matsv</groupId>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>viabackwards-parent</artifactId>
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
<groupId>nl.matsv</groupId>
|
<groupId>nl.matsv</groupId>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -12,17 +12,22 @@ package nl.matsv.viabackwards.api;
|
|||||||
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2.Protocol1_12_1To1_12_2;
|
import nl.matsv.viabackwards.protocol.protocol1_12_1to1_12_2.Protocol1_12_1To1_12_2;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_12_1.Protocol1_12To1_12_1;
|
import nl.matsv.viabackwards.protocol.protocol1_12to1_12_1.Protocol1_12To1_12_1;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2.Protocol1_14_1To1_14_2;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3.Protocol1_14_2To1_14_3;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
|
||||||
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
|
||||||
|
import us.myles.ViaVersion.update.Version;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -40,8 +45,13 @@ public interface ViaBackwardsPlatform {
|
|||||||
ProtocolRegistry.registerProtocol(new Protocol1_11_1To1_12(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_12.getId());
|
ProtocolRegistry.registerProtocol(new Protocol1_11_1To1_12(), Collections.singletonList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_12.getId());
|
||||||
ProtocolRegistry.registerProtocol(new Protocol1_12To1_12_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_12_1.getId());
|
ProtocolRegistry.registerProtocol(new Protocol1_12To1_12_1(), Collections.singletonList(ProtocolVersion.v1_12.getId()), ProtocolVersion.v1_12_1.getId());
|
||||||
ProtocolRegistry.registerProtocol(new Protocol1_12_1To1_12_2(), Collections.singletonList(ProtocolVersion.v1_12_1.getId()), ProtocolVersion.v1_12_2.getId());
|
ProtocolRegistry.registerProtocol(new Protocol1_12_1To1_12_2(), Collections.singletonList(ProtocolVersion.v1_12_1.getId()), ProtocolVersion.v1_12_2.getId());
|
||||||
ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId())
|
ProtocolRegistry.registerProtocol(new Protocol1_12_2To1_13(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_13.getId());
|
||||||
ProtocolRegistry.registerProtocol(new Protocol1_12_2To1_13(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_13.getId())
|
ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId());
|
||||||
|
ProtocolRegistry.registerProtocol(new Protocol1_13_1To1_13_2(), Collections.singletonList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13_2.getId());
|
||||||
|
ProtocolRegistry.registerProtocol(new Protocol1_13_2To1_14(), Collections.singletonList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_14.getId());
|
||||||
|
ProtocolRegistry.registerProtocol(new Protocol1_14To1_14_1(), Collections.singletonList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_14_1.getId());
|
||||||
|
ProtocolRegistry.registerProtocol(new Protocol1_14_1To1_14_2(), Collections.singletonList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14_2.getId());
|
||||||
|
ProtocolRegistry.registerProtocol(new Protocol1_14_2To1_14_3(), Collections.singletonList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_3.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,21 +62,22 @@ public interface ViaBackwardsPlatform {
|
|||||||
*/
|
*/
|
||||||
Logger getLogger();
|
Logger getLogger();
|
||||||
|
|
||||||
// TODO remove or better implement later
|
|
||||||
default boolean isOutdated() {
|
default boolean isOutdated() {
|
||||||
|
String minimumVVVersion = "2.0.0";
|
||||||
boolean upToDate = false;
|
boolean upToDate = false;
|
||||||
try {
|
try {
|
||||||
Class<?> clazz = Class.forName("us.myles.ViaVersion.api.protocol.ProtocolVersion");
|
Class<?> vvVersionInfo = Class.forName("us.myles.ViaVersion.sponge.VersionInfo");
|
||||||
Field v1_13 = clazz.getField("v1_13");
|
String vvVersion = (String) vvVersionInfo.getField("VERSION").get(null);
|
||||||
|
|
||||||
upToDate = (v1_13 != null);
|
upToDate = (vvVersion != null
|
||||||
} catch (ClassNotFoundException | NoSuchFieldException ignored) {
|
&& new Version(vvVersion).compareTo(new Version(minimumVVVersion + "--")) >= 0);
|
||||||
|
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException ignored) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!upToDate) {
|
if (!upToDate) {
|
||||||
getLogger().severe("================================");
|
getLogger().severe("================================");
|
||||||
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
getLogger().severe("YOUR VIAVERSION IS OUTDATED");
|
||||||
getLogger().severe("PLEASE USE THE LATEST VERSION");
|
getLogger().severe("PLEASE USE VIAVERSION " + minimumVVVersion + " OR NEWER");
|
||||||
getLogger().severe("LINK: https://viaversion.com");
|
getLogger().severe("LINK: https://viaversion.com");
|
||||||
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
getLogger().severe("VIABACKWARDS WILL NOW DISABLE");
|
||||||
getLogger().severe("================================");
|
getLogger().severe("================================");
|
||||||
|
@ -0,0 +1,319 @@
|
|||||||
|
package nl.matsv.viabackwards.api.entities.types;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
|
public class EntityType1_13 {
|
||||||
|
|
||||||
|
public static EntityType getTypeFromId(int typeID, boolean isObject) {
|
||||||
|
Optional<EntityType> type;
|
||||||
|
|
||||||
|
if (isObject)
|
||||||
|
type = ObjectType.getPCEntity(typeID);
|
||||||
|
else
|
||||||
|
type = EntityType.findById(typeID);
|
||||||
|
|
||||||
|
if (!type.isPresent()) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().severe("[EntityType1_13] Could not find type id " + typeID + " isObject=" + isObject);
|
||||||
|
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||||
|
}
|
||||||
|
|
||||||
|
return type.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum EntityType implements AbstractEntityType {
|
||||||
|
|
||||||
|
|
||||||
|
ENTITY(-1), // abm
|
||||||
|
|
||||||
|
AREA_EFFECT_CLOUD(0, ENTITY), // abk
|
||||||
|
ENDER_CRYSTAL(16, ENTITY), // aho
|
||||||
|
EVOCATION_FANGS(20, ENTITY), // ala
|
||||||
|
XP_ORB(22, ENTITY), // abs
|
||||||
|
EYE_OF_ENDER_SIGNAL(23, ENTITY), // alb
|
||||||
|
FALLING_BLOCK(24, ENTITY), // aix
|
||||||
|
FIREWORKS_ROCKET(25, ENTITY), // alc
|
||||||
|
ITEM(32, ENTITY), // aiy
|
||||||
|
LLAMA_SPIT(37, ENTITY), // ale
|
||||||
|
TNT(55, ENTITY), // aiz
|
||||||
|
SHULKER_BULLET(60, ENTITY), // alh
|
||||||
|
FISHING_BOBBER(93, ENTITY), // ais
|
||||||
|
|
||||||
|
LIVINGENTITY(-1, ENTITY), // abv
|
||||||
|
ARMOR_STAND(1, LIVINGENTITY), // ail
|
||||||
|
PLAYER(92, LIVINGENTITY), // aks
|
||||||
|
|
||||||
|
ABSTRACT_INSENTIENT(-1, LIVINGENTITY), // abw
|
||||||
|
ENDER_DRAGON(17, ABSTRACT_INSENTIENT), // ahp
|
||||||
|
|
||||||
|
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT), // acd
|
||||||
|
|
||||||
|
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE), // abj
|
||||||
|
VILLAGER(79, ABSTRACT_AGEABLE), // akn
|
||||||
|
|
||||||
|
// Animals
|
||||||
|
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE), // agd
|
||||||
|
CHICKEN(7, ABSTRACT_ANIMAL), // age
|
||||||
|
COW(9, ABSTRACT_ANIMAL), // agg
|
||||||
|
MOOSHROOM(47, COW), // agi
|
||||||
|
PIG(51, ABSTRACT_ANIMAL), // agl
|
||||||
|
POLAR_BEAR(54, ABSTRACT_ANIMAL), // agm
|
||||||
|
RABBIT(56, ABSTRACT_ANIMAL), // ago
|
||||||
|
SHEEP(58, ABSTRACT_ANIMAL), // agq
|
||||||
|
TURTLE(73, ABSTRACT_ANIMAL), // agv
|
||||||
|
|
||||||
|
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL), // acg
|
||||||
|
OCELOT(48, ABSTRACT_TAMEABLE_ANIMAL), // agj
|
||||||
|
WOLF(86, ABSTRACT_TAMEABLE_ANIMAL), // agy
|
||||||
|
|
||||||
|
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL), // agr
|
||||||
|
PARROT(50, ABSTRACT_PARROT), // agk
|
||||||
|
|
||||||
|
|
||||||
|
// Horses
|
||||||
|
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL), // aha
|
||||||
|
CHESTED_HORSE(-1, ABSTRACT_HORSE), // agz
|
||||||
|
DONKEY(11, CHESTED_HORSE), // ahb
|
||||||
|
MULE(46, CHESTED_HORSE), // ahf
|
||||||
|
LLAMA(36, CHESTED_HORSE), // ahe
|
||||||
|
HORSE(29, ABSTRACT_HORSE), // ahc
|
||||||
|
SKELETON_HORSE(63, ABSTRACT_HORSE), // ahg
|
||||||
|
ZOMBIE_HORSE(88, ABSTRACT_HORSE), // ahi
|
||||||
|
|
||||||
|
// Golem
|
||||||
|
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), // agc
|
||||||
|
SNOWMAN(66, ABSTRACT_GOLEM), // ags
|
||||||
|
VILLAGER_GOLEM(80, ABSTRACT_GOLEM), // agw
|
||||||
|
SHULKER(59, ABSTRACT_GOLEM), // ajx
|
||||||
|
|
||||||
|
// Fish
|
||||||
|
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE), // agb
|
||||||
|
COD_MOB(8, ABSTRACT_FISHES), // agf
|
||||||
|
PUFFER_FISH(52, ABSTRACT_FISHES), // agn
|
||||||
|
SALMON_MOB(57, ABSTRACT_FISHES), // agp
|
||||||
|
TROPICAL_FISH(72, ABSTRACT_FISHES), // agu
|
||||||
|
|
||||||
|
// Monsters
|
||||||
|
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE), // ajs
|
||||||
|
BLAZE(4, ABSTRACT_MONSTER), // ajd
|
||||||
|
CREEPER(10, ABSTRACT_MONSTER), // ajf
|
||||||
|
ENDERMITE(19, ABSTRACT_MONSTER), // ajj
|
||||||
|
ENDERMAN(18, ABSTRACT_MONSTER), // aji
|
||||||
|
GIANT(27, ABSTRACT_MONSTER), // ajn
|
||||||
|
SILVERFISH(61, ABSTRACT_MONSTER), // ajy
|
||||||
|
VEX(78, ABSTRACT_MONSTER), // ake
|
||||||
|
WITCH(82, ABSTRACT_MONSTER), // akg
|
||||||
|
WITHER(83, ABSTRACT_MONSTER), // aij
|
||||||
|
|
||||||
|
// Illagers
|
||||||
|
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER), // ajb
|
||||||
|
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE), // akb
|
||||||
|
EVOCATION_ILLAGER(21, ABSTRACT_EVO_ILLU_ILLAGER), // ajl
|
||||||
|
ILLUSION_ILLAGER(31, ABSTRACT_EVO_ILLU_ILLAGER), // ajq
|
||||||
|
VINDICATION_ILLAGER(81, ABSTRACT_ILLAGER_BASE), // akf
|
||||||
|
|
||||||
|
// Skeletons
|
||||||
|
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), // ajc
|
||||||
|
SKELETON(62, ABSTRACT_SKELETON), // ajz
|
||||||
|
STRAY(71, ABSTRACT_SKELETON), // akd
|
||||||
|
WITHER_SKELETON(84, ABSTRACT_SKELETON), // akh
|
||||||
|
|
||||||
|
// Guardians
|
||||||
|
GUARDIAN(28, ABSTRACT_MONSTER), // ajo
|
||||||
|
ELDER_GUARDIAN(15, GUARDIAN), // ajh
|
||||||
|
|
||||||
|
// Spiders
|
||||||
|
SPIDER(69, ABSTRACT_MONSTER), // akc
|
||||||
|
CAVE_SPIDER(6, SPIDER), // aje
|
||||||
|
|
||||||
|
// Zombies - META CHECKED
|
||||||
|
ZOMBIE(87, ABSTRACT_MONSTER), // aki
|
||||||
|
DROWNED(14, ZOMBIE), // ajg
|
||||||
|
HUSK(30, ZOMBIE), // ajp
|
||||||
|
ZOMBIE_PIGMAN(53, ZOMBIE), // aju
|
||||||
|
ZOMBIE_VILLAGER(89, ZOMBIE), // akj
|
||||||
|
|
||||||
|
// Flying entities
|
||||||
|
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT), // abt
|
||||||
|
GHAST(26, ABSTRACT_FLYING), // ajm
|
||||||
|
PHANTOM(90, ABSTRACT_FLYING), // ajt
|
||||||
|
|
||||||
|
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT), // afy
|
||||||
|
BAT(3, ABSTRACT_AMBIENT), // afz
|
||||||
|
|
||||||
|
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT), // agx
|
||||||
|
SQUID(70, ABSTRACT_WATERMOB), // agt
|
||||||
|
DOLPHIN(12, ABSTRACT_WATERMOB), // ajq
|
||||||
|
|
||||||
|
// Slimes
|
||||||
|
SLIME(64, ABSTRACT_INSENTIENT), // aka
|
||||||
|
MAGMA_CUBE(38, SLIME), // ajr
|
||||||
|
|
||||||
|
// Hangable objects
|
||||||
|
ABSTRACT_HANGING(-1, ENTITY), // aim
|
||||||
|
LEASH_KNOT(35, ABSTRACT_HANGING), // aio
|
||||||
|
ITEM_FRAME(33, ABSTRACT_HANGING), // ain
|
||||||
|
PAINTING(49, ABSTRACT_HANGING), // aiq
|
||||||
|
|
||||||
|
ABSTRACT_LIGHTNING(-1, ENTITY), // aiu
|
||||||
|
LIGHTNING_BOLT(91, ABSTRACT_LIGHTNING), // aiv
|
||||||
|
|
||||||
|
// Arrows
|
||||||
|
ABSTRACT_ARROW(-1, ENTITY), // akw
|
||||||
|
ARROW(2, ABSTRACT_ARROW), // aky
|
||||||
|
SPECTRAL_ARROW(68, ABSTRACT_ARROW), // alk
|
||||||
|
TRIDENT(94, ABSTRACT_ARROW), // alq
|
||||||
|
|
||||||
|
// Fireballs
|
||||||
|
ABSTRACT_FIREBALL(-1, ENTITY), // akx
|
||||||
|
DRAGON_FIREBALL(13, ABSTRACT_FIREBALL), // akz
|
||||||
|
FIREBALL(34, ABSTRACT_FIREBALL), // ald
|
||||||
|
SMALL_FIREBALL(65, ABSTRACT_FIREBALL), // ali
|
||||||
|
WITHER_SKULL(85, ABSTRACT_FIREBALL), // alr
|
||||||
|
|
||||||
|
// Projectiles
|
||||||
|
PROJECTILE_ABSTRACT(-1, ENTITY), // all
|
||||||
|
SNOWBALL(67, PROJECTILE_ABSTRACT), // alj
|
||||||
|
ENDER_PEARL(75, PROJECTILE_ABSTRACT), // aln
|
||||||
|
EGG(74, PROJECTILE_ABSTRACT), // alm
|
||||||
|
POTION(77, PROJECTILE_ABSTRACT), // alp
|
||||||
|
XP_BOTTLE(76, PROJECTILE_ABSTRACT), // alo
|
||||||
|
|
||||||
|
// Vehicles
|
||||||
|
MINECART_ABSTRACT(-1, ENTITY), // alt
|
||||||
|
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT), // alu
|
||||||
|
CHEST_MINECART(40, CHESTED_MINECART_ABSTRACT), // alx
|
||||||
|
HOPPER_MINECART(43, CHESTED_MINECART_ABSTRACT), // ama
|
||||||
|
MINECART(39, MINECART_ABSTRACT), // alw
|
||||||
|
FURNACE_MINECART(42, MINECART_ABSTRACT), // alz
|
||||||
|
COMMANDBLOCK_MINECART(41, MINECART_ABSTRACT), // aly
|
||||||
|
TNT_MINECART(45, MINECART_ABSTRACT), // amc
|
||||||
|
SPAWNER_MINECART(44, MINECART_ABSTRACT), // amb
|
||||||
|
BOAT(5, ENTITY); // alv
|
||||||
|
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
private final EntityType parent;
|
||||||
|
|
||||||
|
EntityType(int id) {
|
||||||
|
this.id = id;
|
||||||
|
this.parent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<EntityType> findById(int id) {
|
||||||
|
if (id == -1) // Check if this is called
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
for (EntityType ent : EntityType.values())
|
||||||
|
if (ent.getId() == id)
|
||||||
|
return Optional.of(ent);
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is(AbstractEntityType... types) {
|
||||||
|
for (AbstractEntityType type : types)
|
||||||
|
if (is(type))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is(AbstractEntityType type) {
|
||||||
|
return this == type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOrHasParent(AbstractEntityType type) {
|
||||||
|
EntityType parent = this;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (parent == type)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
parent = parent.getParent();
|
||||||
|
} while (parent != null);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractEntityType> getParents() {
|
||||||
|
List<AbstractEntityType> types = new ArrayList<>();
|
||||||
|
EntityType parent = this;
|
||||||
|
|
||||||
|
do {
|
||||||
|
types.add(parent);
|
||||||
|
parent = parent.getParent();
|
||||||
|
} while (parent != null);
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum ObjectType implements AbstractObjectType {
|
||||||
|
BOAT(1, EntityType.BOAT),
|
||||||
|
ITEM(2, EntityType.ITEM),
|
||||||
|
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
||||||
|
MINECART(10, EntityType.MINECART_ABSTRACT),
|
||||||
|
TNT_PRIMED(50, EntityType.TNT),
|
||||||
|
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
||||||
|
TIPPED_ARROW(60, EntityType.ARROW),
|
||||||
|
SNOWBALL(61, EntityType.SNOWBALL),
|
||||||
|
EGG(62, EntityType.EGG),
|
||||||
|
FIREBALL(63, EntityType.FIREBALL),
|
||||||
|
SMALL_FIREBALL(64, EntityType.SMALL_FIREBALL),
|
||||||
|
ENDER_PEARL(65, EntityType.ENDER_PEARL),
|
||||||
|
WITHER_SKULL(66, EntityType.WITHER_SKULL),
|
||||||
|
SHULKER_BULLET(67, EntityType.SHULKER_BULLET),
|
||||||
|
LIAMA_SPIT(68, EntityType.LLAMA_SPIT),
|
||||||
|
FALLING_BLOCK(70, EntityType.FALLING_BLOCK),
|
||||||
|
ITEM_FRAME(71, EntityType.ITEM_FRAME),
|
||||||
|
ENDER_SIGNAL(72, EntityType.EYE_OF_ENDER_SIGNAL),
|
||||||
|
POTION(73, EntityType.POTION),
|
||||||
|
THROWN_EXP_BOTTLE(75, EntityType.XP_BOTTLE),
|
||||||
|
FIREWORK(76, EntityType.FIREWORKS_ROCKET),
|
||||||
|
LEASH(77, EntityType.LEASH_KNOT),
|
||||||
|
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||||
|
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
|
||||||
|
FISHIHNG_HOOK(90, EntityType.FISHING_BOBBER),
|
||||||
|
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||||
|
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
|
||||||
|
TRIDENT(94, EntityType.TRIDENT);
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
private final EntityType type;
|
||||||
|
|
||||||
|
public static Optional<ObjectType> findById(int id) {
|
||||||
|
if (id == -1)
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
|
for (ObjectType ent : ObjectType.values())
|
||||||
|
if (ent.getId() == id)
|
||||||
|
return Optional.of(ent);
|
||||||
|
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<EntityType> getPCEntity(int id) {
|
||||||
|
Optional<ObjectType> output = findById(id);
|
||||||
|
|
||||||
|
return output.map(ObjectType::getType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<ObjectType> fromEntityType(EntityType type) {
|
||||||
|
for (ObjectType ent : ObjectType.values())
|
||||||
|
if (ent.getType() == type)
|
||||||
|
return Optional.of(ent);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,258 @@
|
|||||||
|
package nl.matsv.viabackwards.api.entities.types;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class EntityType1_14 {
|
||||||
|
public static EntityType1_14.EntityType getTypeFromId(int typeID) {
|
||||||
|
Optional<EntityType> type = EntityType.findById(typeID);
|
||||||
|
|
||||||
|
if (!type.isPresent()) {
|
||||||
|
ViaBackwards.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 implements AbstractEntityType {
|
||||||
|
// Auto generated
|
||||||
|
|
||||||
|
ENTITY(-1),
|
||||||
|
|
||||||
|
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||||
|
ENDER_CRYSTAL(17, ENTITY),
|
||||||
|
EVOCATION_FANGS(21, ENTITY),
|
||||||
|
XP_ORB(23, ENTITY),
|
||||||
|
EYE_OF_ENDER_SIGNAL(24, ENTITY),
|
||||||
|
FALLING_BLOCK(25, ENTITY),
|
||||||
|
FIREWORKS_ROCKET(26, ENTITY),
|
||||||
|
ITEM(34, ENTITY),
|
||||||
|
LLAMA_SPIT(39, ENTITY),
|
||||||
|
TNT(58, ENTITY),
|
||||||
|
SHULKER_BULLET(63, ENTITY),
|
||||||
|
FISHING_BOBBER(101, ENTITY),
|
||||||
|
|
||||||
|
LIVINGENTITY(-1, ENTITY),
|
||||||
|
ARMOR_STAND(1, LIVINGENTITY),
|
||||||
|
PLAYER(100, LIVINGENTITY),
|
||||||
|
|
||||||
|
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
||||||
|
ENDER_DRAGON(18, ABSTRACT_INSENTIENT),
|
||||||
|
|
||||||
|
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||||
|
|
||||||
|
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||||
|
VILLAGER(84, ABSTRACT_AGEABLE),
|
||||||
|
WANDERING_TRADER(88, ABSTRACT_AGEABLE),
|
||||||
|
|
||||||
|
// Animals
|
||||||
|
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||||
|
DOLPHIN(13, ABSTRACT_INSENTIENT),
|
||||||
|
CHICKEN(8, ABSTRACT_ANIMAL),
|
||||||
|
COW(10, ABSTRACT_ANIMAL),
|
||||||
|
MOOSHROOM(49, COW),
|
||||||
|
PANDA(52, ABSTRACT_INSENTIENT),
|
||||||
|
PIG(54, ABSTRACT_ANIMAL),
|
||||||
|
POLAR_BEAR(57, ABSTRACT_ANIMAL),
|
||||||
|
RABBIT(59, ABSTRACT_ANIMAL),
|
||||||
|
SHEEP(61, ABSTRACT_ANIMAL),
|
||||||
|
TURTLE(77, ABSTRACT_ANIMAL),
|
||||||
|
FOX(27, ABSTRACT_ANIMAL),
|
||||||
|
|
||||||
|
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||||
|
CAT(6, ABSTRACT_TAMEABLE_ANIMAL),
|
||||||
|
OCELOT(50, ABSTRACT_TAMEABLE_ANIMAL),
|
||||||
|
WOLF(93, ABSTRACT_TAMEABLE_ANIMAL),
|
||||||
|
|
||||||
|
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||||
|
PARROT(53, ABSTRACT_PARROT),
|
||||||
|
|
||||||
|
// Horses
|
||||||
|
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||||
|
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||||
|
DONKEY(12, CHESTED_HORSE),
|
||||||
|
MULE(48, CHESTED_HORSE),
|
||||||
|
LLAMA(38, CHESTED_HORSE),
|
||||||
|
TRADER_LLAMA(75, CHESTED_HORSE),
|
||||||
|
HORSE(31, ABSTRACT_HORSE),
|
||||||
|
SKELETON_HORSE(66, ABSTRACT_HORSE),
|
||||||
|
ZOMBIE_HORSE(95, ABSTRACT_HORSE),
|
||||||
|
|
||||||
|
// Golem
|
||||||
|
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||||
|
SNOWMAN(69, ABSTRACT_GOLEM),
|
||||||
|
VILLAGER_GOLEM(85, ABSTRACT_GOLEM),
|
||||||
|
SHULKER(62, ABSTRACT_GOLEM),
|
||||||
|
|
||||||
|
// Fish
|
||||||
|
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||||
|
COD(9, ABSTRACT_FISHES),
|
||||||
|
PUFFER_FISH(55, ABSTRACT_FISHES),
|
||||||
|
SALMON_MOB(60, ABSTRACT_FISHES),
|
||||||
|
TROPICAL_FISH(76, ABSTRACT_FISHES),
|
||||||
|
|
||||||
|
// Monsters
|
||||||
|
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||||
|
BLAZE(4, ABSTRACT_MONSTER),
|
||||||
|
CREEPER(11, ABSTRACT_MONSTER),
|
||||||
|
ENDERMITE(20, ABSTRACT_MONSTER),
|
||||||
|
ENDERMAN(19, ABSTRACT_MONSTER),
|
||||||
|
GIANT(29, ABSTRACT_MONSTER),
|
||||||
|
SILVERFISH(64, ABSTRACT_MONSTER),
|
||||||
|
VEX(83, ABSTRACT_MONSTER),
|
||||||
|
WITCH(89, ABSTRACT_MONSTER),
|
||||||
|
WITHER(90, ABSTRACT_MONSTER),
|
||||||
|
RAVAGER(98, ABSTRACT_MONSTER),
|
||||||
|
|
||||||
|
// Illagers
|
||||||
|
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||||
|
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||||
|
EVOCATION_ILLAGER(22, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||||
|
ILLUSION_ILLAGER(33, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||||
|
VINDICATION_ILLAGER(86, ABSTRACT_ILLAGER_BASE),
|
||||||
|
PILLAGER(87, ABSTRACT_ILLAGER_BASE),
|
||||||
|
|
||||||
|
// Skeletons
|
||||||
|
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||||
|
SKELETON(65, ABSTRACT_SKELETON),
|
||||||
|
STRAY(74, ABSTRACT_SKELETON),
|
||||||
|
WITHER_SKELETON(91, ABSTRACT_SKELETON),
|
||||||
|
|
||||||
|
// Guardians
|
||||||
|
GUARDIAN(30, ABSTRACT_MONSTER),
|
||||||
|
ELDER_GUARDIAN(16, GUARDIAN),
|
||||||
|
|
||||||
|
// Spiders
|
||||||
|
SPIDER(72, ABSTRACT_MONSTER),
|
||||||
|
CAVE_SPIDER(7, SPIDER),
|
||||||
|
|
||||||
|
// Zombies - META CHECKED
|
||||||
|
ZOMBIE(94, ABSTRACT_MONSTER),
|
||||||
|
DROWNED(15, ZOMBIE),
|
||||||
|
HUSK(32, ZOMBIE),
|
||||||
|
ZOMBIE_PIGMAN(56, ZOMBIE),
|
||||||
|
ZOMBIE_VILLAGER(96, ZOMBIE),
|
||||||
|
|
||||||
|
// Flying entities
|
||||||
|
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||||
|
GHAST(28, ABSTRACT_FLYING),
|
||||||
|
PHANTOM(97, ABSTRACT_FLYING),
|
||||||
|
|
||||||
|
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||||
|
BAT(3, ABSTRACT_AMBIENT),
|
||||||
|
|
||||||
|
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||||
|
SQUID(73, ABSTRACT_WATERMOB),
|
||||||
|
|
||||||
|
// Slimes
|
||||||
|
SLIME(67, ABSTRACT_INSENTIENT),
|
||||||
|
MAGMA_CUBE(40, SLIME),
|
||||||
|
|
||||||
|
// Hangable objects
|
||||||
|
ABSTRACT_HANGING(-1, ENTITY),
|
||||||
|
LEASH_KNOT(37, ABSTRACT_HANGING),
|
||||||
|
ITEM_FRAME(35, ABSTRACT_HANGING),
|
||||||
|
PAINTING(51, ABSTRACT_HANGING),
|
||||||
|
|
||||||
|
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||||
|
LIGHTNING_BOLT(99, ABSTRACT_LIGHTNING),
|
||||||
|
|
||||||
|
// Arrows
|
||||||
|
ABSTRACT_ARROW(-1, ENTITY),
|
||||||
|
ARROW(2, ABSTRACT_ARROW),
|
||||||
|
SPECTRAL_ARROW(71, ABSTRACT_ARROW),
|
||||||
|
TRIDENT(82, ABSTRACT_ARROW),
|
||||||
|
|
||||||
|
// Fireballs
|
||||||
|
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||||
|
DRAGON_FIREBALL(14, ABSTRACT_FIREBALL),
|
||||||
|
FIREBALL(36, ABSTRACT_FIREBALL),
|
||||||
|
SMALL_FIREBALL(68, ABSTRACT_FIREBALL),
|
||||||
|
WITHER_SKULL(92, ABSTRACT_FIREBALL),
|
||||||
|
|
||||||
|
// Projectiles
|
||||||
|
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||||
|
SNOWBALL(70, PROJECTILE_ABSTRACT),
|
||||||
|
ENDER_PEARL(79, PROJECTILE_ABSTRACT),
|
||||||
|
EGG(78, PROJECTILE_ABSTRACT),
|
||||||
|
POTION(81, PROJECTILE_ABSTRACT),
|
||||||
|
XP_BOTTLE(80, PROJECTILE_ABSTRACT),
|
||||||
|
|
||||||
|
// Vehicles
|
||||||
|
MINECART_ABSTRACT(-1, ENTITY),
|
||||||
|
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||||
|
CHEST_MINECART(42, CHESTED_MINECART_ABSTRACT),
|
||||||
|
HOPPER_MINECART(45, CHESTED_MINECART_ABSTRACT),
|
||||||
|
MINECART(41, MINECART_ABSTRACT),
|
||||||
|
FURNACE_MINECART(44, MINECART_ABSTRACT),
|
||||||
|
COMMANDBLOCK_MINECART(43, MINECART_ABSTRACT),
|
||||||
|
TNT_MINECART(47, MINECART_ABSTRACT),
|
||||||
|
SPAWNER_MINECART(46, MINECART_ABSTRACT),
|
||||||
|
BOAT(5, ENTITY),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int id;
|
||||||
|
private final EntityType parent;
|
||||||
|
|
||||||
|
EntityType(int id) {
|
||||||
|
this.id = id;
|
||||||
|
this.parent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static java.util.Optional<EntityType> findById(int id) {
|
||||||
|
if (id == -1) // Check if this is called
|
||||||
|
return java.util.Optional.empty();
|
||||||
|
|
||||||
|
for (EntityType ent : EntityType.values())
|
||||||
|
if (ent.getId() == id)
|
||||||
|
return java.util.Optional.of(ent);
|
||||||
|
|
||||||
|
return java.util.Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is(AbstractEntityType... types) {
|
||||||
|
for (AbstractEntityType type : types)
|
||||||
|
if (is(type))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is(AbstractEntityType type) {
|
||||||
|
return this == type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOrHasParent(AbstractEntityType type) {
|
||||||
|
EntityType parent = this;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (parent == type)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
parent = parent.getParent();
|
||||||
|
} while (parent != null);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractEntityType> getParents() {
|
||||||
|
List<AbstractEntityType> types = new ArrayList<>();
|
||||||
|
EntityType parent = this;
|
||||||
|
|
||||||
|
do {
|
||||||
|
types.add(parent);
|
||||||
|
parent = parent.getParent();
|
||||||
|
} while (parent != null);
|
||||||
|
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ import lombok.ToString;
|
|||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
import nl.matsv.viabackwards.api.entities.blockitem.BlockItemSettings;
|
import nl.matsv.viabackwards.api.entities.blockitem.BlockItemSettings;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.BlockColors;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import nl.matsv.viabackwards.utils.ItemUtil;
|
import nl.matsv.viabackwards.utils.ItemUtil;
|
||||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
@ -88,8 +88,9 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Item handleItemToServer(Item item) {
|
protected Item handleItemToServer(Item item) {
|
||||||
if (item == null || item.getTag() == null)
|
if (item == null) return null;
|
||||||
return null;
|
if (item.getTag() == null) return item;
|
||||||
|
|
||||||
CompoundTag tag = item.getTag();
|
CompoundTag tag = item.getTag();
|
||||||
if (tag.contains("ViaBackwards|" + getProtocolName())) {
|
if (tag.contains("ViaBackwards|" + getProtocolName())) {
|
||||||
CompoundTag via = tag.get("ViaBackwards|" + getProtocolName());
|
CompoundTag via = tag.get("ViaBackwards|" + getProtocolName());
|
||||||
@ -138,10 +139,18 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
|||||||
if (!(tag.contains("x") && tag.contains("y") && tag.contains("z")))
|
if (!(tag.contains("x") && tag.contains("y") && tag.contains("z")))
|
||||||
continue;
|
continue;
|
||||||
Pos pos = new Pos(
|
Pos pos = new Pos(
|
||||||
(int) tag.get("x").getValue() % 16,
|
(int) tag.get("x").getValue() & 0xF,
|
||||||
(int) tag.get("y").getValue(),
|
(int) tag.get("y").getValue(),
|
||||||
(int) tag.get("z").getValue() % 16);
|
(int) tag.get("z").getValue() & 0xF);
|
||||||
tags.put(pos, tag);
|
tags.put(pos, tag);
|
||||||
|
|
||||||
|
// Handle given Block Entities
|
||||||
|
ChunkSection section = chunk.getSections()[pos.getY() >> 4];
|
||||||
|
if (section == null) continue;
|
||||||
|
int block = section.getFlatBlock(pos.getX(), pos.getY() & 0xF, pos.getZ());
|
||||||
|
int btype = block >> 4;
|
||||||
|
if (!hasBlockEntityHandler(btype)) continue;
|
||||||
|
replacementData.get(btype).getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||||
@ -149,32 +158,45 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
|||||||
if (section == null)
|
if (section == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
boolean hasBlockEntityHandler = false;
|
||||||
|
|
||||||
|
// Map blocks
|
||||||
|
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||||
|
int block = section.getPaletteEntry(j);
|
||||||
|
int btype = block >> 4;
|
||||||
|
int meta = block & 0xF;
|
||||||
|
|
||||||
|
if (containsBlock(btype)) {
|
||||||
|
Block b = handleBlock(btype, meta);
|
||||||
|
section.setPaletteEntry(j, (b.getId() << 4) | (b.getData() & 0xF));
|
||||||
|
}
|
||||||
|
|
||||||
|
hasBlockEntityHandler = hasBlockEntityHandler || hasBlockEntityHandler(btype);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hasBlockEntityHandler) continue;
|
||||||
|
|
||||||
|
// We need to handle a Block Entity :(
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int x = 0; x < 16; x++) {
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
for (int z = 0; z < 16; z++) {
|
for (int z = 0; z < 16; z++) {
|
||||||
int block = section.getBlock(x, y, z);
|
int block = section.getFlatBlock(x, y, z);
|
||||||
int btype = block >> 4;
|
int btype = block >> 4;
|
||||||
int meta = block & 15;
|
int meta = block & 15;
|
||||||
|
|
||||||
if (containsBlock(btype)) {
|
if (!hasBlockEntityHandler(btype)) continue;
|
||||||
Block b = handleBlock(btype, meta); // Type / data
|
|
||||||
section.setBlock(x, y, z, b.getId(), b.getData());
|
Pos pos = new Pos(x, (y + (i << 4)), z);
|
||||||
}
|
|
||||||
// Entity Tags
|
// Already handled above
|
||||||
if (hasBlockEntityHandler(btype)) {
|
if (tags.containsKey(pos)) continue;
|
||||||
Pos pos = new Pos(x, (y + (i << 4)), z);
|
|
||||||
CompoundTag tag = null;
|
CompoundTag tag = new CompoundTag("");
|
||||||
if (tags.containsKey(pos)) {
|
tag.put(new IntTag("x", x + (chunk.getX() << 4)));
|
||||||
tag = tags.get(pos);
|
tag.put(new IntTag("y", y + (i << 4)));
|
||||||
} else {
|
tag.put(new IntTag("z", z + (chunk.getZ() << 4)));
|
||||||
tag = new CompoundTag("");
|
replacementData.get(btype).getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||||
tag.put(new IntTag("x", x + (chunk.getX() << 4)));
|
chunk.getBlockEntities().add(tag);
|
||||||
tag.put(new IntTag("y", y + (i << 4)));
|
|
||||||
tag.put(new IntTag("z", z + (chunk.getZ() << 4)));
|
|
||||||
chunk.getBlockEntities().add(tag);
|
|
||||||
}
|
|
||||||
replacementData.get(btype).getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
|
|||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
||||||
import us.myles.ViaVersion.exception.CancelException;
|
import us.myles.ViaVersion.exception.CancelException;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -51,6 +52,9 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
|
|||||||
@Getter(AccessLevel.PROTECTED)
|
@Getter(AccessLevel.PROTECTED)
|
||||||
@Setter(AccessLevel.PROTECTED)
|
@Setter(AccessLevel.PROTECTED)
|
||||||
private int displayNameIndex = 2;
|
private int displayNameIndex = 2;
|
||||||
|
@Getter(AccessLevel.PROTECTED)
|
||||||
|
@Setter(AccessLevel.PROTECTED)
|
||||||
|
private boolean isDisplayNameJson = false;
|
||||||
|
|
||||||
protected AbstractEntityType getEntityType(UserConnection connection, int id) {
|
protected AbstractEntityType getEntityType(UserConnection connection, int id) {
|
||||||
return getEntityTracker(connection).getEntityType(id);
|
return getEntityTracker(connection).getEntityType(id);
|
||||||
@ -60,6 +64,10 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
|
|||||||
getEntityTracker(connection).trackEntityType(entityId, type);
|
getEntityTracker(connection).trackEntityType(entityId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean hasData(AbstractEntityType type) {
|
||||||
|
return entityTypes.containsKey(type);
|
||||||
|
}
|
||||||
|
|
||||||
protected Optional<EntityData> getEntityData(AbstractEntityType type) {
|
protected Optional<EntityData> getEntityData(AbstractEntityType type) {
|
||||||
if (!entityTypes.containsKey(type))
|
if (!entityTypes.containsKey(type))
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
@ -144,8 +152,13 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
|
|||||||
EntityData entData = opEd.get();
|
EntityData entData = opEd.get();
|
||||||
if (entData.getMobName() != null &&
|
if (entData.getMobName() != null &&
|
||||||
(data.getValue() == null || ((String) data.getValue()).isEmpty()) &&
|
(data.getValue() == null || ((String) data.getValue()).isEmpty()) &&
|
||||||
data.getMetaType().getTypeID() == getDisplayNameMetaType().getTypeID())
|
data.getMetaType().getTypeID() == getDisplayNameMetaType().getTypeID()) {
|
||||||
data.setValue(entData.getMobName());
|
String mobName = entData.getMobName();
|
||||||
|
if (isDisplayNameJson) {
|
||||||
|
mobName = ChatRewriter.legacyTextToJson(mobName);
|
||||||
|
}
|
||||||
|
data.setValue(mobName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,17 +18,18 @@ import nl.matsv.viabackwards.protocol.protocol1_10to1_11.EntityTypeNames;
|
|||||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.BlockColors;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
@ -226,7 +227,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
|
|||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
|
||||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||||
Chunk1_9_3_4 chunk = (Chunk1_9_3_4) wrapper.passthrough(type);
|
Chunk chunk = wrapper.passthrough(type);
|
||||||
|
|
||||||
handleChunk(chunk);
|
handleChunk(chunk);
|
||||||
|
|
||||||
@ -269,18 +270,13 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
|
|||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.INT); // 0 - Chunk X
|
map(Type.INT); // 0 - Chunk X
|
||||||
map(Type.INT); // 1 - Chunk Z
|
map(Type.INT); // 1 - Chunk Z
|
||||||
|
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int count = wrapper.passthrough(Type.VAR_INT); // Array length
|
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||||
|
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Horizontal position
|
|
||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Y coords
|
|
||||||
|
|
||||||
int id = wrapper.read(Type.VAR_INT); // Block ID
|
|
||||||
wrapper.write(Type.VAR_INT, handleBlockID(id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|||||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
|
|
||||||
public class PlayerPackets1_11 {
|
public class PlayerPackets1_11 {
|
||||||
private static final ValueTransformer<Short, Float> toNewFloat = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
private static final ValueTransformer<Short, Float> toNewFloat = new ValueTransformer<Short, Float>(Type.FLOAT) {
|
||||||
@ -45,10 +45,13 @@ public class PlayerPackets1_11 {
|
|||||||
if (action == 2) {
|
if (action == 2) {
|
||||||
// Convert to the old actionbar way
|
// Convert to the old actionbar way
|
||||||
PacketWrapper actionbar = new PacketWrapper(0x0F, null, wrapper.user()); // Chat Message packet
|
PacketWrapper actionbar = new PacketWrapper(0x0F, null, wrapper.user()); // Chat Message packet
|
||||||
actionbar.write(Type.STRING, wrapper.read(Type.STRING));
|
String msg = wrapper.read(Type.STRING);
|
||||||
|
msg = ChatRewriter.jsonTextToLegacy(msg);
|
||||||
|
msg = "{\"text\":\"" + msg + "\"}";
|
||||||
|
actionbar.write(Type.STRING, msg);
|
||||||
actionbar.write(Type.BYTE, (byte) 2); // Above hotbar
|
actionbar.write(Type.BYTE, (byte) 2); // Above hotbar
|
||||||
|
|
||||||
actionbar.send(Protocol1_11To1_10.class);
|
actionbar.send(Protocol1_10To1_11.class);
|
||||||
|
|
||||||
wrapper.cancel(); // Cancel the title packet
|
wrapper.cancel(); // Cancel the title packet
|
||||||
return;
|
return;
|
||||||
|
@ -8,19 +8,19 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.ShoulderTracker;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets.*;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets.*;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class Protocol1_11_1To1_12 extends BackwardsProtocol {
|
public class Protocol1_11_1To1_12 extends BackwardsProtocol {
|
||||||
// TODO store all rewriters and make them easy accessible?
|
// TODO checkAndStore all rewriters and make them easy accessible?
|
||||||
private EntityPackets1_12 entityPackets;
|
private EntityPackets1_12 entityPackets;
|
||||||
private BlockItemPackets1_12 blockItemPackets;
|
private BlockItemPackets1_12 blockItemPackets;
|
||||||
|
|
@ -8,7 +8,7 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
@ -8,7 +8,7 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
@ -1,4 +1,4 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
@ -8,7 +8,7 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityStorage;
|
import nl.matsv.viabackwards.api.entities.storage.EntityStorage;
|
@ -8,7 +8,7 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -20,7 +20,7 @@ import us.myles.ViaVersion.api.data.StoredObject;
|
|||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -37,7 +37,7 @@ public class ShoulderTracker extends StoredObject {
|
|||||||
public void update() {
|
public void update() {
|
||||||
PacketWrapper wrapper = new PacketWrapper(0x0F, null, getUser());
|
PacketWrapper wrapper = new PacketWrapper(0x0F, null, getUser());
|
||||||
|
|
||||||
wrapper.write(Type.STRING, Protocol1_9TO1_8.fixJson(generateString()));
|
wrapper.write(Type.STRING, Protocol1_9To1_8.fixJson(generateString()));
|
||||||
wrapper.write(Type.BYTE, (byte) 2);
|
wrapper.write(Type.BYTE, (byte) 2);
|
||||||
|
|
||||||
try {
|
try {
|
@ -8,24 +8,26 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.BlockColors;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.BlockColors;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.MapColorMapping;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.MapColorMapping;
|
||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
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.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.DoubleTag;
|
||||||
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -171,6 +173,24 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
|
||||||
|
// https://github.com/ViaVersion/ViaVersion/pull/754
|
||||||
|
// Previously clients grab the item from the clicked slot *before* it has
|
||||||
|
// been moved however now they grab the slot item *after* it has been moved
|
||||||
|
// and send that in the packet.
|
||||||
|
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
|
||||||
|
|
||||||
|
// Apologize (may happen in some cases, maybe if inventory is full?)
|
||||||
|
PacketWrapper confirm = wrapper.create(0x6);
|
||||||
|
confirm.write(Type.BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue());
|
||||||
|
confirm.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
|
||||||
|
confirm.write(Type.BOOLEAN, false); // Success - not used
|
||||||
|
|
||||||
|
wrapper.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||||
|
wrapper.cancel();
|
||||||
|
confirm.sendToServer(Protocol1_11_1To1_12.class, true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
Item item = wrapper.get(Type.ITEM, 0);
|
Item item = wrapper.get(Type.ITEM, 0);
|
||||||
handleItemToServer(item);
|
handleItemToServer(item);
|
||||||
}
|
}
|
||||||
@ -209,7 +229,7 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
|
|||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
|
||||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
|
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
|
||||||
Chunk1_9_3_4 chunk = (Chunk1_9_3_4) wrapper.passthrough(type);
|
Chunk chunk = wrapper.passthrough(type);
|
||||||
|
|
||||||
handleChunk(chunk);
|
handleChunk(chunk);
|
||||||
}
|
}
|
||||||
@ -242,18 +262,13 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
|
|||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.INT); // 0 - Chunk X
|
map(Type.INT); // 0 - Chunk X
|
||||||
map(Type.INT); // 1 - Chunk Z
|
map(Type.INT); // 1 - Chunk Z
|
||||||
|
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int count = wrapper.passthrough(Type.VAR_INT); // Array length
|
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||||
|
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Horizontal position
|
|
||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Y coords
|
|
||||||
|
|
||||||
int id = wrapper.read(Type.VAR_INT); // Block ID
|
|
||||||
wrapper.write(Type.VAR_INT, handleBlockID(id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -8,10 +8,10 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
@ -87,7 +87,7 @@ public class ChangedPacketIds1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
|||||||
p.registerOutgoing(State.PLAY, 0x4D, 0x4A); // Entity Properties
|
p.registerOutgoing(State.PLAY, 0x4D, 0x4A); // Entity Properties
|
||||||
p.registerOutgoing(State.PLAY, 0x4E, 0x4B); // Entity Effect
|
p.registerOutgoing(State.PLAY, 0x4E, 0x4B); // Entity Effect
|
||||||
|
|
||||||
p.registerIncoming(State.PLAY, 0x01, -1); // Prepare Crafting Grid
|
// New incoming packet 0x01 - Prepare Crafting Grid
|
||||||
p.registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (Serverbound)
|
p.registerIncoming(State.PLAY, 0x02, 0x01); // Tab-Complete (Serverbound)
|
||||||
p.registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (Serverbound)
|
p.registerIncoming(State.PLAY, 0x03, 0x02); // Chat Message (Serverbound)
|
||||||
// 0x04->0x03 Client Status handled in BlockItemPackets1_12.java
|
// 0x04->0x03 Client Status handled in BlockItemPackets1_12.java
|
||||||
@ -109,9 +109,9 @@ public class ChangedPacketIds1_12 extends Rewriter<Protocol1_11_1To1_12> {
|
|||||||
p.registerIncoming(State.PLAY, 0x14, 0x13); // Player Digging
|
p.registerIncoming(State.PLAY, 0x14, 0x13); // Player Digging
|
||||||
p.registerIncoming(State.PLAY, 0x15, 0x14); // Entity Action
|
p.registerIncoming(State.PLAY, 0x15, 0x14); // Entity Action
|
||||||
p.registerIncoming(State.PLAY, 0x16, 0x15); // Steer Vehicle
|
p.registerIncoming(State.PLAY, 0x16, 0x15); // Steer Vehicle
|
||||||
p.registerIncoming(State.PLAY, 0x17, -1); // Crafting Book Data
|
// New incoming packet 0x17 - Crafting Book Data
|
||||||
p.registerIncoming(State.PLAY, 0x18, 0x16); // Resource Pack Status
|
p.registerIncoming(State.PLAY, 0x18, 0x16); // Resource Pack Status
|
||||||
p.registerIncoming(State.PLAY, 0x19, -1); // Advancement Tab
|
// New incoming packet 0x19 - Advancement Tab
|
||||||
p.registerIncoming(State.PLAY, 0x1A, 0x17); // Held Item Change (Serverbound)
|
p.registerIncoming(State.PLAY, 0x1A, 0x17); // Held Item Change (Serverbound)
|
||||||
// 0x1B -> 0x18 Creative Inventory Action handled in BlockItemPackets.java
|
// 0x1B -> 0x18 Creative Inventory Action handled in BlockItemPackets.java
|
||||||
p.registerIncoming(State.PLAY, 0x1C, 0x19); // Update Sign
|
p.registerIncoming(State.PLAY, 0x1C, 0x19); // Update Sign
|
@ -8,12 +8,12 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.AdvancementTranslations;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.AdvancementTranslations;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
@ -8,7 +8,7 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.ViaBackwards;
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
@ -17,9 +17,9 @@ import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
|||||||
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
||||||
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.ParrotStorage;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ParrotStorage;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.ShoulderTracker;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.data.ShoulderTracker;
|
||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
@ -8,10 +8,10 @@
|
|||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.packets;
|
package nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.packets;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
import nl.matsv.viabackwards.protocol.protocol1_11_1to1_12.Protocol1_11_1To1_12;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
@ -10,75 +10,63 @@
|
|||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.SoundMapping;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.EntityPackets1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.PlayerPacket1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.SoundPackets1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.platform.providers.ViaProviders;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
|
@Getter
|
||||||
public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
||||||
|
|
||||||
|
private BlockItemPackets1_13 blockItemPackets;
|
||||||
|
|
||||||
|
static {
|
||||||
|
BackwardsMappings.init();
|
||||||
|
PaintingMapping.init();
|
||||||
|
SoundMapping.init();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
new BlockItemPackets1_13().register(this);
|
(blockItemPackets = new BlockItemPackets1_13()).register(this);
|
||||||
|
new EntityPackets1_13().register(this);
|
||||||
|
new PlayerPacket1_13().register(this);
|
||||||
|
new SoundPackets1_13().register(this);
|
||||||
|
|
||||||
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150
|
// Thanks to https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150
|
||||||
|
|
||||||
|
|
||||||
out(State.PLAY, 0x00, 0x00, cancel());
|
|
||||||
out(State.PLAY, 0x04, 0x04, cancel());// Spawn Painting TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x07, 0x07, cancel()); // Statistics TODO MODIFIED
|
out(State.PLAY, 0x07, 0x07, cancel()); // Statistics TODO MODIFIED
|
||||||
out(State.PLAY, 0x09, 0x09, cancel()); // Update Block Entity TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x0B, 0x0B, cancel()); // Block Change TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x0E, 0x0F); // Chat Message (clientbound)
|
out(State.PLAY, 0x0E, 0x0F); // Chat Message (clientbound)
|
||||||
out(State.PLAY, 0x0F, 0x10, cancel()); // Multi Block Change TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x10, 0x0E, cancel()); // Tab-Complete (clientbound) TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
|
out(State.PLAY, 0x11, -1, cancel()); // Declare Commands TODO NEW
|
||||||
out(State.PLAY, 0x12, 0x11, cancel()); // Confirm Transaction (clientbound)
|
out(State.PLAY, 0x12, 0x11); // Confirm Transaction (clientbound)
|
||||||
out(State.PLAY, 0x13, 0x12, cancel()); // Close Window (clientbound)
|
out(State.PLAY, 0x13, 0x12); // Close Window (clientbound)
|
||||||
out(State.PLAY, 0x14, 0x13, cancel()); // Open Window
|
out(State.PLAY, 0x14, 0x13); // Open Window
|
||||||
out(State.PLAY, 0x15, 0x14, cancel()); // Window Items
|
out(State.PLAY, 0x16, 0x15); // Window Property
|
||||||
out(State.PLAY, 0x16, 0x15, cancel()); // Window Property
|
out(State.PLAY, 0x18, 0x17); // Set Cooldown
|
||||||
out(State.PLAY, 0x17, 0x16, cancel()); // Set Slot
|
|
||||||
out(State.PLAY, 0x18, 0x17); // Set Cooldown
|
|
||||||
out(State.PLAY, 0x19, 0x18); // Plugin Message (clientbound) TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x1A, 0x19, cancel()); // Named Sound Effect TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x1B, 0x1A); // Disconnect (play)
|
out(State.PLAY, 0x1B, 0x1A); // Disconnect (play)
|
||||||
out(State.PLAY, 0x1C, 0x1B); // Entity Status
|
out(State.PLAY, 0x1C, 0x1B); // Entity Status
|
||||||
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response TODO NEW
|
out(State.PLAY, 0x1D, -1, cancel()); // NBT Query Response (client won't send a request, so the server should not answer)
|
||||||
out(State.PLAY, 0x1E, 0x1C); // Explosion
|
out(State.PLAY, 0x1E, 0x1C); // Explosion
|
||||||
out(State.PLAY, 0x1F, 0x1D); // Unload Chunk
|
out(State.PLAY, 0x1F, 0x1D); // Unload Chunk
|
||||||
out(State.PLAY, 0x20, 0x1E); // Change Game State
|
out(State.PLAY, 0x20, 0x1E); // Change Game State
|
||||||
out(State.PLAY, 0x21, 0x1F); // Keep Alive (clientbound)
|
out(State.PLAY, 0x21, 0x1F); // Keep Alive (clientbound)
|
||||||
|
|
||||||
// Chunk Data -> moved to BlockItemPackets
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
out(State.PLAY, 0x23, 0x21, cancel()); // Effect TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x24, 0x22, cancel()); // Spawn Particle TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x25, 0x23, 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 {
|
|
||||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
|
||||||
int dimensionId = wrapper.get(Type.INT, 1);
|
|
||||||
clientChunks.setEnvironment(dimensionId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}); // Join Game
|
|
||||||
out(State.PLAY, 0x26, 0x24, cancel()); // Map TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x27, 0x25); // Entity
|
out(State.PLAY, 0x27, 0x25); // Entity
|
||||||
out(State.PLAY, 0x28, 0x26); // Entity Relative Move
|
out(State.PLAY, 0x28, 0x26); // Entity Relative Move
|
||||||
out(State.PLAY, 0x29, 0x27); // Entity Look And Relative Move
|
out(State.PLAY, 0x29, 0x27); // Entity Look And Relative Move
|
||||||
@ -88,55 +76,39 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
|||||||
out(State.PLAY, 0x2D, 0x2B, cancel()); // Craft Recipe Response TODO MODIFIED
|
out(State.PLAY, 0x2D, 0x2B, cancel()); // Craft Recipe Response TODO MODIFIED
|
||||||
out(State.PLAY, 0x2E, 0x2C); // Player Abilities (clientbound)
|
out(State.PLAY, 0x2E, 0x2C); // Player Abilities (clientbound)
|
||||||
out(State.PLAY, 0x2F, 0x2D); // Combat Event
|
out(State.PLAY, 0x2F, 0x2D); // Combat Event
|
||||||
out(State.PLAY, 0x30, 0x2E); // Player List Item
|
|
||||||
out(State.PLAY, 0x31, -1, cancel()); // Face Player TODO NEW
|
out(State.PLAY, 0x31, -1, cancel()); // Face Player TODO NEW
|
||||||
out(State.PLAY, 0x32, 0x2F); // Player Position And Look (clientbound)
|
out(State.PLAY, 0x32, 0x2F); // Player Position And Look (clientbound)
|
||||||
out(State.PLAY, 0x33, 0x30); // Use Bed
|
out(State.PLAY, 0x33, 0x30); // Use Bed
|
||||||
out(State.PLAY, 0x34, 0x31, cancel()); // Unlock Recipes TODO MODIFIED
|
out(State.PLAY, 0x34, 0x31, cancel()); // Unlock Recipes TODO MODIFIED
|
||||||
out(State.PLAY, 0x35, 0x32); // Destroy Entities
|
|
||||||
out(State.PLAY, 0x36, 0x33); // Remove Entity Effect
|
out(State.PLAY, 0x36, 0x33); // Remove Entity Effect
|
||||||
out(State.PLAY, 0x37, 0x34); // Resource Pack Send
|
out(State.PLAY, 0x37, 0x34); // Resource Pack Send
|
||||||
out(State.PLAY, 0x38, 0x35); // Respawn
|
|
||||||
out(State.PLAY, 0x39, 0x36); // Entity Head Look
|
out(State.PLAY, 0x39, 0x36); // Entity Head Look
|
||||||
out(State.PLAY, 0x3A, 0x37); // Select Advancement Tab
|
out(State.PLAY, 0x3A, 0x37); // Select Advancement Tab
|
||||||
out(State.PLAY, 0x3B, 0x38); // World Border
|
out(State.PLAY, 0x3B, 0x38); // World Border
|
||||||
out(State.PLAY, 0x3C, 0x39); // Camera
|
out(State.PLAY, 0x3C, 0x39); // Camera
|
||||||
out(State.PLAY, 0x3D, 0x3A, cancel()); // Held Item Change (clientbound)
|
out(State.PLAY, 0x3D, 0x3A); // Held Item Change (clientbound)
|
||||||
out(State.PLAY, 0x3E, 0x3B); // Display Scoreboard
|
out(State.PLAY, 0x3E, 0x3B); // Display Scoreboard
|
||||||
out(State.PLAY, 0x3F, 0x3C, cancel()); // Entity Metadata
|
|
||||||
out(State.PLAY, 0x40, 0x3D); // Attach Entity
|
out(State.PLAY, 0x40, 0x3D); // Attach Entity
|
||||||
out(State.PLAY, 0x41, 0x3E); // Entity Velocity
|
out(State.PLAY, 0x41, 0x3E); // Entity Velocity
|
||||||
out(State.PLAY, 0x42, 0x3F, cancel()); // Entity Equipment
|
|
||||||
out(State.PLAY, 0x43, 0x40); // Set Experience
|
out(State.PLAY, 0x43, 0x40); // Set Experience
|
||||||
out(State.PLAY, 0x44, 0x41); // Update Health
|
out(State.PLAY, 0x44, 0x41); // Update Health
|
||||||
out(State.PLAY, 0x45, 0x42, cancel()); // Scoreboard Objective TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x46, 0x43); // Set Passengers
|
out(State.PLAY, 0x46, 0x43); // Set Passengers
|
||||||
out(State.PLAY, 0x47, 0x44, cancel()); // Teams TODO MODIFIED
|
|
||||||
out(State.PLAY, 0x48, 0x45); // Update Score
|
out(State.PLAY, 0x48, 0x45); // Update Score
|
||||||
out(State.PLAY, 0x49, 0x46); // Spawn Position
|
out(State.PLAY, 0x49, 0x46); // Spawn Position
|
||||||
out(State.PLAY, 0x4A, 0x47); // Time Update
|
out(State.PLAY, 0x4A, 0x47); // Time Update
|
||||||
out(State.PLAY, 0x4B, 0x48); // Title
|
out(State.PLAY, 0x4B, 0x48); // Title
|
||||||
out(State.PLAY, 0x4C, -1, cancel()); // Stop Sound TODO NEW
|
|
||||||
out(State.PLAY, 0x4D, 0x49); // Sound Effect
|
|
||||||
out(State.PLAY, 0x4E, 0x4A); // Player List Header And Footer
|
out(State.PLAY, 0x4E, 0x4A); // Player List Header And Footer
|
||||||
out(State.PLAY, 0x4F, 0x4B, cancel()); // Collect Item
|
out(State.PLAY, 0x4F, 0x4B); // Collect Item
|
||||||
out(State.PLAY, 0x50, 0x4C); // Entity Teleport
|
out(State.PLAY, 0x50, 0x4C); // Entity Teleport
|
||||||
out(State.PLAY, 0x51, 0x4D, cancel()); // Advancements
|
out(State.PLAY, 0x51, 0x4D, cancel()); // Advancements
|
||||||
out(State.PLAY, 0x52, 0x4E); // Entity Properties
|
out(State.PLAY, 0x52, 0x4E); // Entity Properties
|
||||||
out(State.PLAY, 0x53, 0x4F); // Entity Effect
|
out(State.PLAY, 0x53, 0x4F); // Entity Effect
|
||||||
out(State.PLAY, 0x54, -1, cancel()); // Declare Recipes TODO NEW
|
out(State.PLAY, 0x54, -1, cancel()); // Declare Recipes TODO NEW
|
||||||
out(State.PLAY, 0x55, -1, cancel()); // Tags TODO NEW
|
out(State.PLAY, 0x55, -1, cancel()); // Tags (the client won't need this)
|
||||||
|
|
||||||
|
in(State.PLAY, 0x06, 0x05); // Confirm Transaction (serverbound)
|
||||||
in(State.PLAY, 0x01, -1, cancel()); // Query Block NBT TODO NEW
|
|
||||||
in(State.PLAY, 0x05, 0x01); // Tab-Complete (serverbound) TODO MODIFIED
|
|
||||||
in(State.PLAY, 0x06, 0x05); //Confirm Transaction (serverbound)
|
|
||||||
in(State.PLAY, 0x07, 0x06); // Enchant Item
|
in(State.PLAY, 0x07, 0x06); // Enchant Item
|
||||||
in(State.PLAY, 0x08, 0x07); // Click Window
|
|
||||||
in(State.PLAY, 0x09, 0x08); // Close Window (serverbound)
|
in(State.PLAY, 0x09, 0x08); // Close Window (serverbound)
|
||||||
in(State.PLAY, 0x0A, 0x09, cancel()); // Plugin message (serverbound) TODO MODIFIED
|
|
||||||
in(State.PLAY, 0x0B, -1, cancel()); // Edit Book TODO NEW
|
|
||||||
in(State.PLAY, 0x0C, -1, cancel()); // Query Entity NBT TODO NEW
|
|
||||||
in(State.PLAY, 0x0D, 0x0A); // Use Entity
|
in(State.PLAY, 0x0D, 0x0A); // Use Entity
|
||||||
in(State.PLAY, 0x0E, 0x0B); // Keep Alive (serverbound)
|
in(State.PLAY, 0x0E, 0x0B); // Keep Alive (serverbound)
|
||||||
in(State.PLAY, 0x0F, 0x0C); // Player
|
in(State.PLAY, 0x0F, 0x0C); // Player
|
||||||
@ -145,23 +117,17 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
|||||||
in(State.PLAY, 0x12, 0x0F); // Player Look
|
in(State.PLAY, 0x12, 0x0F); // Player Look
|
||||||
in(State.PLAY, 0x13, 0x10); // Vehicle Move (serverbound)
|
in(State.PLAY, 0x13, 0x10); // Vehicle Move (serverbound)
|
||||||
in(State.PLAY, 0x14, 0x11); // Steer Boat
|
in(State.PLAY, 0x14, 0x11); // Steer Boat
|
||||||
in(State.PLAY, 0x15, -1, cancel()); // Pick Item TODO NEW
|
|
||||||
in(State.PLAY, 0x16, 0x12, cancel()); // Craft Recipe Request TODO MODIFIED
|
in(State.PLAY, 0x16, 0x12, cancel()); // Craft Recipe Request TODO MODIFIED
|
||||||
in(State.PLAY, 0x17, 0x13); // Player Abilities (serverbound)
|
in(State.PLAY, 0x17, 0x13); // Player Abilities (serverbound)
|
||||||
in(State.PLAY, 0x18, 0x14); // Player Digging
|
in(State.PLAY, 0x18, 0x14); // Player Digging
|
||||||
in(State.PLAY, 0x19, 0x15); // Entity Action
|
in(State.PLAY, 0x19, 0x15); // Entity Action
|
||||||
in(State.PLAY, 0x1A, 0x16); // Steer Vehicle
|
in(State.PLAY, 0x1A, 0x16); // Steer Vehicle
|
||||||
in(State.PLAY, 0x1B, 0x17); // Recipe Book Data
|
in(State.PLAY, 0x1B, 0x17, cancel()); // Recipe Book Data TODO MODIFIED
|
||||||
in(State.PLAY, 0x1C, -1, cancel()); // Name Item TODO NEW
|
|
||||||
in(State.PLAY, 0x1D, 0x18); // Resource Pack Status
|
in(State.PLAY, 0x1D, 0x18); // Resource Pack Status
|
||||||
in(State.PLAY, 0x1E, 0x19); // Advancement Tab
|
in(State.PLAY, 0x1E, 0x19); // Advancement Tab
|
||||||
in(State.PLAY, 0x1F, -1); // Select Trade
|
in(State.PLAY, 0x1F, -1); // Select Trade
|
||||||
in(State.PLAY, 0x20, -1); // Set Beacon Effect
|
in(State.PLAY, 0x20, -1); // Set Beacon Effect
|
||||||
in(State.PLAY, 0x21, 0x1A); // Held Item Change (serverbound)
|
in(State.PLAY, 0x21, 0x1A); // Held Item Change (serverbound)
|
||||||
in(State.PLAY, 0x22, -1, cancel()); // Update Command Block TODO NEW
|
|
||||||
in(State.PLAY, 0x23, -1, cancel()); // Update Command Block Minecart TODO NEW
|
|
||||||
in(State.PLAY, 0x24, 0x1B); // Creative Inventory Action
|
|
||||||
in(State.PLAY, 0x25, -1, cancel()); // Update Structure Block TODO NEW
|
|
||||||
in(State.PLAY, 0x26, 0x1C); // Update Sign
|
in(State.PLAY, 0x26, 0x1C); // Update Sign
|
||||||
in(State.PLAY, 0x27, 0x1D); // Animation (serverbound)
|
in(State.PLAY, 0x27, 0x1D); // Animation (serverbound)
|
||||||
in(State.PLAY, 0x28, 0x1E); // Spectate
|
in(State.PLAY, 0x28, 0x1E); // Spectate
|
||||||
@ -176,6 +142,24 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
|||||||
if (!user.has(ClientWorld.class))
|
if (!user.has(ClientWorld.class))
|
||||||
user.put(new ClientWorld(user));
|
user.put(new ClientWorld(user));
|
||||||
|
|
||||||
|
// Register EntityTracker if it doesn't exist yet.
|
||||||
|
if (!user.has(EntityTracker.class))
|
||||||
|
user.put(new EntityTracker(user));
|
||||||
|
|
||||||
|
// Init protocol in EntityTracker
|
||||||
|
user.get(EntityTracker.class).initProtocol(this);
|
||||||
|
|
||||||
|
// Register Block Storage
|
||||||
|
if (!user.has(BackwardsBlockStorage.class))
|
||||||
|
user.put(new BackwardsBlockStorage(user));
|
||||||
|
// Register Block Storage
|
||||||
|
if (!user.has(TabCompleteStorage.class))
|
||||||
|
user.put(new TabCompleteStorage(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void register(ViaProviders providers) {
|
||||||
|
providers.register(BackwardsBlockEntityProvider.class, new BackwardsBlockEntityProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketRemapper cancel() {
|
public PacketRemapper cancel() {
|
||||||
@ -192,8 +176,4 @@ public class Protocol1_12_2To1_13 extends BackwardsProtocol {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
|
||||||
BackwardsMappings.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
|
|
||||||
|
public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||||
|
private final int WALL_BANNER_START = 7110; // 4 each
|
||||||
|
private final int WALL_BANNER_STOP = 7173;
|
||||||
|
|
||||||
|
private final int BANNER_START = 6854; // 16 each
|
||||||
|
private final int BANNER_STOP = 7109;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||||
|
// Normal banners
|
||||||
|
if (blockId >= BANNER_START && blockId <= BANNER_STOP) {
|
||||||
|
int color = (blockId - BANNER_START) >> 4;
|
||||||
|
tag.put(new IntTag("Base", (15 - color)));
|
||||||
|
}
|
||||||
|
// Wall banners
|
||||||
|
else if (blockId >= WALL_BANNER_START && blockId <= WALL_BANNER_STOP) {
|
||||||
|
int color = (blockId - WALL_BANNER_START) >> 2;
|
||||||
|
tag.put(new IntTag("Base", (15 - color)));
|
||||||
|
} else {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invert colors
|
||||||
|
if (tag.contains("Patterns") && tag.get("Patterns") instanceof ListTag) {
|
||||||
|
for (Tag pattern : (ListTag) tag.get("Patterns")) {
|
||||||
|
if (pattern instanceof CompoundTag) {
|
||||||
|
IntTag c = ((CompoundTag) pattern).get("Color");
|
||||||
|
c.setValue(15 - c.getValue()); // Invert color id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
|
|
||||||
|
public class BedHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||||
|
int offset = blockId - 748;
|
||||||
|
int color = offset >> 4;
|
||||||
|
|
||||||
|
tag.put(new IntTag("color", color));
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
|
import us.myles.ViaVersion.api.Pair;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class FlowerPotHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
|
|
||||||
|
private static final Map<Integer, Pair<String, Byte>> flowers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
register(5265, "minecraft:air", (byte) 0);
|
||||||
|
register(5266, "minecraft:sapling", (byte) 0);
|
||||||
|
register(5267, "minecraft:sapling", (byte) 1);
|
||||||
|
register(5268, "minecraft:sapling", (byte) 2);
|
||||||
|
register(5269, "minecraft:sapling", (byte) 3);
|
||||||
|
register(5270, "minecraft:sapling", (byte) 4);
|
||||||
|
register(5271, "minecraft:sapling", (byte) 5);
|
||||||
|
register(5272, "minecraft:tallgrass", (byte) 2);
|
||||||
|
register(5273, "minecraft:yellow_flower", (byte) 0);
|
||||||
|
register(5274, "minecraft:red_flower", (byte) 0);
|
||||||
|
register(5275, "minecraft:red_flower", (byte) 1);
|
||||||
|
register(5276, "minecraft:red_flower", (byte) 2);
|
||||||
|
register(5277, "minecraft:red_flower", (byte) 3);
|
||||||
|
register(5278, "minecraft:red_flower", (byte) 4);
|
||||||
|
register(5279, "minecraft:red_flower", (byte) 5);
|
||||||
|
register(5280, "minecraft:red_flower", (byte) 6);
|
||||||
|
register(5281, "minecraft:red_flower", (byte) 7);
|
||||||
|
register(5282, "minecraft:red_flower", (byte) 8);
|
||||||
|
register(5283, "minecraft:red_mushroom", (byte) 0);
|
||||||
|
register(5284, "minecraft:brown_mushroom", (byte) 0);
|
||||||
|
register(5285, "minecraft:deadbush", (byte) 0);
|
||||||
|
register(5286, "minecraft:cactus", (byte) 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void register(int id, String identifier, byte data) {
|
||||||
|
flowers.put(id, new Pair<>(identifier, data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFlowah(int id) {
|
||||||
|
return flowers.containsKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Pair<String, Byte> getOrDefault(int blockId) {
|
||||||
|
if (flowers.containsKey(blockId))
|
||||||
|
return flowers.get(blockId);
|
||||||
|
|
||||||
|
return flowers.get(5265);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO THIS IS NEVER CALLED BECAUSE ITS NO LONGER A BLOCK ENTITY :(
|
||||||
|
@Override
|
||||||
|
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||||
|
Pair<String, Byte> item = getOrDefault(blockId);
|
||||||
|
|
||||||
|
tag.put(new StringTag("Item", item.getKey()));
|
||||||
|
tag.put(new IntTag("Data", item.getValue()));
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
|
||||||
|
public class SkullHandler implements BackwardsBlockEntityHandler {
|
||||||
|
private final int SKULL_START = 5447;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||||
|
int pos = (blockId - SKULL_START) % 20;
|
||||||
|
byte type = (byte) Math.floor((blockId - SKULL_START) / 20);
|
||||||
|
|
||||||
|
// Set type
|
||||||
|
tag.put(new ByteTag("SkullType", type));
|
||||||
|
|
||||||
|
// Remove wall skulls
|
||||||
|
if (pos < 4) {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add rotation for normal skulls
|
||||||
|
tag.put(new ByteTag("Rot", (byte) ((pos - 4) & 255)));
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.EntityNameRewrites;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
|
||||||
|
public class SpawnerHandler implements BackwardsBlockEntityProvider.BackwardsBlockEntityHandler {
|
||||||
|
@Override
|
||||||
|
public CompoundTag transform(UserConnection user, int blockId, CompoundTag tag) {
|
||||||
|
if (tag.contains("SpawnData") && tag.get("SpawnData") instanceof CompoundTag) {
|
||||||
|
CompoundTag data = tag.get("SpawnData");
|
||||||
|
if (data.contains("id") && data.get("id") instanceof StringTag) {
|
||||||
|
StringTag s = data.get("id");
|
||||||
|
s.setValue(EntityNameRewrites.rewrite(s.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
}
|
@ -10,35 +10,59 @@
|
|||||||
|
|
||||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
import us.myles.ViaVersion.api.Via;
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData;
|
||||||
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
import us.myles.viaversion.libs.gson.JsonElement;
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
import us.myles.viaversion.libs.gson.JsonObject;
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
|
|
||||||
|
|
||||||
public class BackwardsMappings {
|
public class BackwardsMappings {
|
||||||
public static BlockMappings blockMappings;
|
public static BlockMappings blockMappings;
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
us.myles.viaversion.libs.gson.JsonObject mapping1_12 = loadData("mapping-1.12.json");
|
us.myles.viaversion.libs.gson.JsonObject mapping1_12 = MappingData.loadData("mapping-1.12.json");
|
||||||
us.myles.viaversion.libs.gson.JsonObject mapping1_13 = loadData("mapping-1.13.json");
|
us.myles.viaversion.libs.gson.JsonObject mapping1_13 = MappingData.loadData("mapping-1.13.json");
|
||||||
|
us.myles.viaversion.libs.gson.JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json");
|
||||||
|
|
||||||
Via.getPlatform().getLogger().info("Loading block mapping...");
|
ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 block mapping...");
|
||||||
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"));
|
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
private static void mapIdentifiers(short[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
|
||||||
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
|
String key = entry.getValue().getAsString();
|
||||||
|
Map.Entry<String, JsonElement> value = findValue(oldIdentifiers, key);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
JsonPrimitive replacement = mapping.getAsJsonPrimitive(key);
|
||||||
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
if (replacement == null && key.contains("[")) {
|
||||||
|
replacement = mapping.getAsJsonPrimitive(key.substring(0, key.indexOf('[')));
|
||||||
|
}
|
||||||
|
if (replacement != null) {
|
||||||
|
if (replacement.getAsString().startsWith("id:")) {
|
||||||
|
String id = replacement.getAsString().replace("id:", "");
|
||||||
|
value = findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString());
|
||||||
|
} else {
|
||||||
|
value = findValue(oldIdentifiers, replacement.getAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||||
|
if (replacement != null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + "/" + replacement.getAsString() + " :( ");
|
||||||
|
} else {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
|
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
|
||||||
}
|
}
|
||||||
@ -55,16 +79,26 @@ public class BackwardsMappings {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JsonObject loadData(String name) {
|
||||||
|
try (InputStreamReader reader = new InputStreamReader(BackwardsMappings.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name))) {
|
||||||
|
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public interface BlockMappings {
|
public interface BlockMappings {
|
||||||
int getNewBlock(int old);
|
int getNewBlock(int old);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BlockMappingsShortArray implements BlockMappings {
|
private static class BlockMappingsShortArray implements BlockMappings {
|
||||||
private short[] oldToNew = new short[4084 * 6];
|
private short[] oldToNew = new short[8582];
|
||||||
|
|
||||||
private BlockMappingsShortArray(JsonObject oldMapping, JsonObject newMapping) {
|
private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||||
Arrays.fill(oldToNew, (short) -1);
|
Arrays.fill(oldToNew, (short) -1);
|
||||||
mapIdentifiers(oldToNew, oldMapping, newMapping);
|
mapIdentifiers(oldToNew, newIdentifiers, oldIdentifiers, mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class EntityNameRewrites {
|
||||||
|
private static Map<String, String> entityNames = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
/*
|
||||||
|
CHANGED NAMES IN 1.13
|
||||||
|
*/
|
||||||
|
reg("commandblock_minecart", "command_block_minecart");
|
||||||
|
reg("ender_crystal", "end_crystal");
|
||||||
|
reg("evocation_fangs", "evoker_fangs");
|
||||||
|
reg("evocation_illager", "evoker");
|
||||||
|
reg("eye_of_ender_signal", "eye_of_ender");
|
||||||
|
reg("fireworks_rocket", "firework_rocket");
|
||||||
|
reg("illusion_illager", "illusioner");
|
||||||
|
reg("snowman", "snow_golem");
|
||||||
|
reg("villager_golem", "iron_golem");
|
||||||
|
reg("vindication_illager", "vindicator");
|
||||||
|
reg("xp_bottle", "experience_bottle");
|
||||||
|
reg("xp_orb", "experience_orb");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void reg(String past, String future) {
|
||||||
|
entityNames.put("minecraft:" + future, "minecraft:" + past);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String rewrite(String entName) {
|
||||||
|
String entityName = entityNames.get(entName);
|
||||||
|
if (entityName != null) {
|
||||||
|
return entityName;
|
||||||
|
}
|
||||||
|
entityName = entityNames.get("minecraft:" + entName);
|
||||||
|
if (entityName != null) {
|
||||||
|
return entityName;
|
||||||
|
} else
|
||||||
|
return entName;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.EntityTypeRewriter;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class EntityTypeMapping {
|
||||||
|
private static Map<Integer, Integer> entityTypes = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Field field = EntityTypeRewriter.class.getDeclaredField("entityTypes");
|
||||||
|
field.setAccessible(true);
|
||||||
|
Map<Integer, Integer> entityTypes = (Map<Integer, Integer>) field.get(null);
|
||||||
|
entityTypes.forEach((type1_12, type1_13) -> EntityTypeMapping.entityTypes.put(type1_13, type1_12));
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Integer> getOldId(int type1_13) {
|
||||||
|
return Optional.ofNullable(entityTypes.get(type1_13));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class NamedSoundMapping {
|
||||||
|
private static Map<String, String> sounds = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Field field = NamedSoundRewriter.class.getDeclaredField("oldToNew");
|
||||||
|
field.setAccessible(true);
|
||||||
|
Map<String, String> sounds = (Map<String, String>) field.get(null);
|
||||||
|
sounds.forEach((sound1_12, sound1_13) -> NamedSoundMapping.sounds.put(sound1_13, sound1_12));
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getOldId(String sound1_13) {
|
||||||
|
return sounds.get(sound1_13);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PaintingMapping {
|
||||||
|
private static Map<Integer, String> paintings = new HashMap<>();
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
add("Kebab");
|
||||||
|
add("Aztec");
|
||||||
|
add("Alban");
|
||||||
|
add("Aztec2");
|
||||||
|
add("Bomb");
|
||||||
|
add("Plant");
|
||||||
|
add("Wasteland");
|
||||||
|
add("Pool");
|
||||||
|
add("Courbet");
|
||||||
|
add("Sea");
|
||||||
|
add("Sunset");
|
||||||
|
add("Creebet");
|
||||||
|
add("Wanderer");
|
||||||
|
add("Graham");
|
||||||
|
add("Match");
|
||||||
|
add("Bust");
|
||||||
|
add("Stage");
|
||||||
|
add("Void");
|
||||||
|
add("SkullAndRoses");
|
||||||
|
add("Wither");
|
||||||
|
add("Fighters");
|
||||||
|
add("Pointer");
|
||||||
|
add("Pigscene");
|
||||||
|
add("BurningSkull");
|
||||||
|
add("Skeleton");
|
||||||
|
add("DonkeyKong");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void add(String motive) {
|
||||||
|
paintings.put(paintings.size(), motive);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getStringId(int id) {
|
||||||
|
return paintings.getOrDefault(id, "kebab");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
|
||||||
|
public class ParticleMapping {
|
||||||
|
private static final ParticleData[] particles;
|
||||||
|
|
||||||
|
static {
|
||||||
|
particles = new ParticleData[]{
|
||||||
|
rewrite(16), // (0->16) minecraft:ambient_entity_effect -> mobSpellAmbient
|
||||||
|
rewrite(20), // (1->20) minecraft:angry_villager -> angryVillager
|
||||||
|
rewrite(35), // (2->35) minecraft:barrier -> barrier
|
||||||
|
rewrite(37, ParticleMapping::blockHandler),
|
||||||
|
// (3->37) minecraft:block -> blockcrack
|
||||||
|
rewrite(4), // (4->4) minecraft:bubble -> bubble
|
||||||
|
rewrite(29), // (5->29) minecraft:cloud -> cloud
|
||||||
|
rewrite(9), // (6->9) minecraft:crit -> crit
|
||||||
|
rewrite(44), // (7->44) minecraft:damage_indicator -> damageIndicator
|
||||||
|
rewrite(42), // (8->42) minecraft:dragon_breath -> dragonbreath
|
||||||
|
rewrite(19), // (9->19) minecraft:dripping_lava -> dripLava
|
||||||
|
rewrite(18), // (10->18) minecraft:dripping_water -> dripWater
|
||||||
|
rewrite(30, ((protocol, wrapper) -> {
|
||||||
|
float r = wrapper.read(Type.FLOAT);
|
||||||
|
float g = wrapper.read(Type.FLOAT);
|
||||||
|
float b = wrapper.read(Type.FLOAT);
|
||||||
|
float scale = wrapper.read(Type.FLOAT);
|
||||||
|
|
||||||
|
// TODO CONVERT DATA TO OFFSET X/Y/Z SPEED/COUNT
|
||||||
|
|
||||||
|
return new Integer[0];
|
||||||
|
})), // (11->30) minecraft:dust -> reddust
|
||||||
|
rewrite(13), // (12->13) minecraft:effect -> spell
|
||||||
|
rewrite(41), // (13->41) minecraft:elder_guardian -> mobappearance
|
||||||
|
rewrite(10), // (14->10) minecraft:enchanted_hit -> magicCrit
|
||||||
|
rewrite(25), // (15->25) minecraft:enchant -> enchantmenttable
|
||||||
|
rewrite(43), // (16->43) minecraft:end_rod -> endRod
|
||||||
|
rewrite(15), // (17->15) minecraft:entity_effect -> mobSpell
|
||||||
|
rewrite(2), // (18->2) minecraft:explosion_emitter -> hugeexplosion
|
||||||
|
rewrite(1), // (19->1) minecraft:explosion -> largeexplode
|
||||||
|
rewrite(46, ParticleMapping::blockHandler),
|
||||||
|
// (20->46) minecraft:falling_dust -> fallingdust
|
||||||
|
rewrite(3), // (21->3) minecraft:firework -> fireworksSpark
|
||||||
|
rewrite(6), // (22->6) minecraft:fishing -> wake
|
||||||
|
rewrite(26), // (23->26) minecraft:flame -> flame
|
||||||
|
rewrite(21), // (24->21) minecraft:happy_villager -> happyVillager
|
||||||
|
rewrite(34), // (25->34) minecraft:heart -> heart
|
||||||
|
rewrite(14), // (26->14) minecraft:instant_effect -> instantSpell
|
||||||
|
rewrite(36, (protocol, wrapper) -> {
|
||||||
|
Item item = protocol.getBlockItemPackets().handleItemToClient(
|
||||||
|
wrapper.read(Type.FLAT_ITEM)
|
||||||
|
);
|
||||||
|
|
||||||
|
return new Integer[]{Integer.valueOf(item.getId()), Integer.valueOf(item.getData())};
|
||||||
|
}), // (27->36) minecraft:item -> iconcrack
|
||||||
|
rewrite(33), // (28->33) minecraft:item_slime -> slime
|
||||||
|
rewrite(31), // (29->31) minecraft:item_snowball -> snowballpoof
|
||||||
|
rewrite(12), // (30->12) minecraft:large_smoke -> largesmoke
|
||||||
|
rewrite(27), // (31->27) minecraft:lava -> lava
|
||||||
|
rewrite(22), // (32->22) minecraft:mycelium -> townaura
|
||||||
|
rewrite(23), // (33->23) minecraft:note -> note
|
||||||
|
rewrite(0), // (34->0) minecraft:poof -> explode
|
||||||
|
rewrite(24), // (35->24) minecraft:portal -> portal
|
||||||
|
rewrite(39), // (36->39) minecraft:rain -> droplet
|
||||||
|
rewrite(11), // (37->11) minecraft:smoke -> smoke
|
||||||
|
rewrite(48), // (38->48) minecraft:spit -> spit
|
||||||
|
rewrite(-1), // (39->-1) minecraft:squid_ink -> squid_ink TODO NEW?
|
||||||
|
rewrite(45), // (40->45) minecraft:sweep_attack -> sweepAttack
|
||||||
|
rewrite(47), // (41->47) minecraft:totem_of_undying -> totem
|
||||||
|
rewrite(7), // (42->7) minecraft:underwater -> suspended
|
||||||
|
rewrite(5), // (43->5) minecraft:splash -> splash
|
||||||
|
rewrite(17), // (44->17) minecraft:witch -> witchMagic
|
||||||
|
rewrite(4), // (45->4) minecraft:bubble_pop -> bubble
|
||||||
|
rewrite(4), // (46->4) minecraft:current_down -> bubble
|
||||||
|
rewrite(4), // (47->4) minecraft:bubble_column_up -> bubble
|
||||||
|
rewrite(-1), // (48->-1) minecraft:nautilus -> nautilus TODO NEW?
|
||||||
|
rewrite(18), // (49->18) minecraft:dolphin -> dripWater
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Integer[] blockHandler(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||||
|
int blockType = BlockItemPackets1_13.toOldId(wrapper.read(Type.VAR_INT));
|
||||||
|
|
||||||
|
int type = blockType >> 4;
|
||||||
|
int meta = blockType & 15;
|
||||||
|
|
||||||
|
return new Integer[]{type + (meta << 12)};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ParticleData getMapping(int id) {
|
||||||
|
return particles[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ParticleData rewrite(int replacementId) {
|
||||||
|
return new ParticleData(replacementId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ParticleData rewrite(int replacementId, ParticleHandler handler) {
|
||||||
|
return new ParticleData(replacementId, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ParticleHandler {
|
||||||
|
Integer[] rewrite(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public static class ParticleData {
|
||||||
|
private final int historyId;
|
||||||
|
private ParticleHandler handler;
|
||||||
|
|
||||||
|
public Integer[] rewriteData(Protocol1_12_2To1_13 protocol, PacketWrapper wrapper) throws Exception {
|
||||||
|
if (handler == null)
|
||||||
|
return new Integer[0];
|
||||||
|
return handler.rewrite(protocol, wrapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import us.myles.viaversion.libs.gson.JsonArray;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
|
||||||
|
|
||||||
|
public class SoundMapping {
|
||||||
|
private static short[] sounds = new short[662];
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
JsonObject mapping1_12 = loadData("mapping-1.12.json");
|
||||||
|
JsonObject mapping1_13 = loadData("mapping-1.13.json");
|
||||||
|
|
||||||
|
Arrays.fill(sounds, (short) -1);
|
||||||
|
mapIdentifiers(sounds, mapping1_13.getAsJsonArray("sounds"), mapping1_12.getAsJsonArray("sounds"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
|
||||||
|
for (int i = 0; i < oldIdentifiers.size(); i++) {
|
||||||
|
JsonElement v = oldIdentifiers.get(i);
|
||||||
|
Integer index = findIndex(newIdentifiers, v.getAsString());
|
||||||
|
if (index == null) continue; //There will be missing sounds, since we are goind backwards
|
||||||
|
output[i] = index.shortValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Integer findIndex(JsonArray array, String value) {
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
JsonElement v = array.get(i);
|
||||||
|
if (v.getAsString().equals(value)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getOldSound(int newSound) {
|
||||||
|
return newSound < 0 || newSound >= sounds.length ? -1 : sounds[newSound];
|
||||||
|
}
|
||||||
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -0,0 +1,496 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_13.EntityType;
|
||||||
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.EntityTypeMapping;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
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_12;
|
||||||
|
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_12;
|
||||||
|
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||||
|
|
||||||
|
//Spawn Object
|
||||||
|
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.UUID);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.INT);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
byte type = wrapper.get(Type.BYTE, 0);
|
||||||
|
EntityType entityType = EntityType1_13.getTypeFromId(type, true);
|
||||||
|
if (entityType == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
entityType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
Optional<EntityType1_13.ObjectType> type = EntityType1_13.ObjectType.findById(wrapper.get(Type.BYTE, 0));
|
||||||
|
if (type.isPresent() && type.get() == EntityType1_13.ObjectType.FALLING_BLOCK) {
|
||||||
|
int blockState = wrapper.get(Type.INT, 0);
|
||||||
|
int combined = BlockItemPackets1_13.toOldId(blockState);
|
||||||
|
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||||
|
wrapper.set(Type.INT, 0, combined);
|
||||||
|
} else if (type.isPresent() && type.get() == EntityType1_13.ObjectType.ITEM_FRAME) {
|
||||||
|
int data = wrapper.get(Type.INT, 0);
|
||||||
|
switch (data) {
|
||||||
|
case 3:
|
||||||
|
data = 0;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
data = 1;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
data = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wrapper.set(Type.INT, 0, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Spawn Experience Orb
|
||||||
|
protocol.out(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.XP_ORB
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Spawn Global Entity
|
||||||
|
protocol.out(State.PLAY, 0x02, 0x02, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.BYTE);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.LIGHTNING_BOLT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Spawn Mob
|
||||||
|
protocol.out(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.UUID);
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.SHORT);
|
||||||
|
map(Type.SHORT);
|
||||||
|
map(Type.SHORT);
|
||||||
|
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
EntityType entityType = EntityType1_13.getTypeFromId(type, false);
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
entityType
|
||||||
|
);
|
||||||
|
Optional<Integer> oldId = EntityTypeMapping.getOldId(type);
|
||||||
|
if (!oldId.isPresent()) {
|
||||||
|
if (!hasData(entityType))
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.12 entity type for 1.13 entity type " + type + "/" + entityType);
|
||||||
|
} else {
|
||||||
|
wrapper.set(Type.VAR_INT, 1, oldId.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle entity type & metadata
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0));
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
storage
|
||||||
|
);
|
||||||
|
|
||||||
|
Optional<EntityData> optEntDat = getEntityData(type);
|
||||||
|
if (optEntDat.isPresent()) {
|
||||||
|
EntityData data = optEntDat.get();
|
||||||
|
|
||||||
|
Optional<Integer> replacementId = EntityTypeMapping.getOldId(data.getReplacementId());
|
||||||
|
wrapper.set(Type.VAR_INT, 1, replacementId.orElse(EntityType1_12.EntityType.ZOMBIE.getId()));
|
||||||
|
if (data.hasBaseMeta())
|
||||||
|
data.getDefaultMeta().handle(storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
wrapper.set(
|
||||||
|
Types1_12.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
storage.getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Player
|
||||||
|
protocol.out(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.UUID);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.DOUBLE);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST);
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.PLAYER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.set(
|
||||||
|
Types1_12.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Spawn Painting
|
||||||
|
protocol.out(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.UUID);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.PAINTING
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int motive = wrapper.read(Type.VAR_INT);
|
||||||
|
String title = PaintingMapping.getStringId(motive);
|
||||||
|
wrapper.write(Type.STRING, title);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Join game
|
||||||
|
protocol.out(State.PLAY, 0x25, 0x23, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Entity ID
|
||||||
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
|
map(Type.INT); // 2 - Dimension
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.INT, 0),
|
||||||
|
EntityType1_12.EntityType.PLAYER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save dimension
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 1);
|
||||||
|
clientChunks.setEnvironment(dimensionId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Respawn Packet (save dimension id)
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x38, 0x35, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Dimension ID
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Destroy Entities Packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x35, 0x32, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||||
|
getEntityTracker(wrapper.user()).removeEntity(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Entity Metadata packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3C, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Types1_13.METADATA_LIST, Types1_12.METADATA_LIST); // 1 - Metadata list
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.set(
|
||||||
|
Types1_12.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
new MetaStorage(wrapper.get(Types1_12.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
// Rewrite new Entity 'drowned'
|
||||||
|
regEntType(EntityType.DROWNED, EntityType.ZOMBIE_VILLAGER).mobName("Drowned");
|
||||||
|
|
||||||
|
// Fishy
|
||||||
|
regEntType(EntityType.COD_MOB, EntityType.SQUID).mobName("Cod");
|
||||||
|
regEntType(EntityType.SALMON_MOB, EntityType.SQUID).mobName("Salmon");
|
||||||
|
regEntType(EntityType.PUFFER_FISH, EntityType.SQUID).mobName("Puffer Fish");
|
||||||
|
regEntType(EntityType.TROPICAL_FISH, EntityType.SQUID).mobName("Tropical Fish");
|
||||||
|
|
||||||
|
// Phantom
|
||||||
|
regEntType(EntityType.PHANTOM, EntityType.PARROT).mobName("Phantom").spawnMetadata(storage -> {
|
||||||
|
// The phantom is grey/blue so let's do yellow/blue
|
||||||
|
storage.add(new Metadata(15, MetaType1_12.VarInt, 3));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Dolphin
|
||||||
|
regEntType(EntityType.DOLPHIN, EntityType.SQUID).mobName("Dolphin");
|
||||||
|
|
||||||
|
// Turtle
|
||||||
|
regEntType(EntityType.TURTLE, EntityType.OCELOT).mobName("Turtle");
|
||||||
|
|
||||||
|
|
||||||
|
// Rewrite Meta types
|
||||||
|
registerMetaHandler().handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
int typeId = meta.getMetaType().getTypeID();
|
||||||
|
|
||||||
|
// Rewrite optional chat to chat
|
||||||
|
if (typeId == 5) {
|
||||||
|
meta.setMetaType(MetaType1_12.String);
|
||||||
|
|
||||||
|
if (meta.getValue() == null) {
|
||||||
|
meta.setValue("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite items
|
||||||
|
else if (typeId == 6) {
|
||||||
|
meta.setMetaType(MetaType1_12.Slot);
|
||||||
|
Item item = (Item) meta.getValue();
|
||||||
|
meta.setValue(getProtocol().getBlockItemPackets().handleItemToClient(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Discontinue particles
|
||||||
|
else if (typeId == 15) {
|
||||||
|
meta.setMetaType(MetaType1_12.Discontinued);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite to 1.12 ids
|
||||||
|
else if (typeId > 5) {
|
||||||
|
meta.setMetaType(MetaType1_12.byId(
|
||||||
|
typeId - 1
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rewrite Custom Name from Chat to String
|
||||||
|
registerMetaHandler().filter(EntityType.ENTITY, true, 2).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
|
meta.setValue(
|
||||||
|
ChatRewriter.jsonTextToLegacy(
|
||||||
|
(String) meta.getValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle zombie metadata
|
||||||
|
registerMetaHandler().filter(EntityType.ZOMBIE, true, 15).removed();
|
||||||
|
registerMetaHandler().filter(EntityType.ZOMBIE, true).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
|
if (meta.getId() > 15) {
|
||||||
|
meta.setId(meta.getId() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle turtle metadata (Remove them all for now)
|
||||||
|
registerMetaHandler().filter(EntityType.TURTLE, 13).removed(); // Home pos
|
||||||
|
registerMetaHandler().filter(EntityType.TURTLE, 14).removed(); // Has egg
|
||||||
|
registerMetaHandler().filter(EntityType.TURTLE, 15).removed(); // Laying egg
|
||||||
|
registerMetaHandler().filter(EntityType.TURTLE, 16).removed(); // Travel pos
|
||||||
|
registerMetaHandler().filter(EntityType.TURTLE, 17).removed(); // Going home
|
||||||
|
registerMetaHandler().filter(EntityType.TURTLE, 18).removed(); // Traveling
|
||||||
|
|
||||||
|
// Remove additional fish meta
|
||||||
|
registerMetaHandler().filter(EntityType.ABSTRACT_FISHES, true, 12).removed();
|
||||||
|
registerMetaHandler().filter(EntityType.ABSTRACT_FISHES, true, 13).removed();
|
||||||
|
|
||||||
|
// Remove phantom size
|
||||||
|
registerMetaHandler().filter(EntityType.PHANTOM, 12).removed();
|
||||||
|
|
||||||
|
// Remove boat splash timer
|
||||||
|
registerMetaHandler().filter(EntityType.BOAT, 12).removed();
|
||||||
|
|
||||||
|
// Remove Trident special loyalty level
|
||||||
|
registerMetaHandler().filter(EntityType.TRIDENT, 7).removed();
|
||||||
|
|
||||||
|
// Handle new wolf colors
|
||||||
|
registerMetaHandler().filter(EntityType.WOLF, 17).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
|
meta.setValue(15 - (int) meta.getValue());
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rewrite AreaEffectCloud
|
||||||
|
registerMetaHandler().filter(EntityType.AREA_EFFECT_CLOUD, 9).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
Particle particle = (Particle) meta.getValue();
|
||||||
|
|
||||||
|
// TODO Rewrite particle ids
|
||||||
|
e.getStorage().add(new Metadata(9, MetaType1_12.VarInt, 0));
|
||||||
|
e.getStorage().add(new Metadata(10, MetaType1_12.VarInt, 0));
|
||||||
|
e.getStorage().add(new Metadata(11, MetaType1_12.VarInt, 0));
|
||||||
|
|
||||||
|
throw new RemovedValueException();
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO REWRITE BLOCKS IN MINECART
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,449 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.ParticleMapping;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.TabCompleteStorage;
|
||||||
|
import nl.matsv.viabackwards.utils.ChatUtil;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
|
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_13to1_12_2.ChatRewriter;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.packets.InventoryPackets;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||||
|
// Login Plugin Request
|
||||||
|
protocol.out(State.LOGIN, 0x04, -1, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||||
|
packetWrapper.cancel();
|
||||||
|
packetWrapper.create(0x02, new ValueCreator() { // Plugin response
|
||||||
|
@Override
|
||||||
|
public void write(PacketWrapper newWrapper) throws Exception {
|
||||||
|
newWrapper.write(Type.VAR_INT, packetWrapper.read(Type.VAR_INT)); // Packet id
|
||||||
|
newWrapper.write(Type.BOOLEAN, false); // Success
|
||||||
|
}
|
||||||
|
}).sendToServer(Protocol1_12_2To1_13.class);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//Plugin Message
|
||||||
|
protocol.out(State.PLAY, 0x19, 0x18, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
String channel = wrapper.read(Type.STRING);
|
||||||
|
if (channel.equals("minecraft:trader_list")) {
|
||||||
|
wrapper.write(Type.STRING, "MC|TrList");
|
||||||
|
wrapper.passthrough(Type.INT); //Passthrough Window ID
|
||||||
|
|
||||||
|
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//Input Item
|
||||||
|
Item input = wrapper.read(Type.FLAT_ITEM);
|
||||||
|
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(input));
|
||||||
|
//Output Item
|
||||||
|
Item output = wrapper.read(Type.FLAT_ITEM);
|
||||||
|
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(output));
|
||||||
|
|
||||||
|
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
|
||||||
|
if (secondItem) {
|
||||||
|
//Second Item
|
||||||
|
Item second = wrapper.read(Type.FLAT_ITEM);
|
||||||
|
wrapper.write(Type.ITEM, getProtocol().getBlockItemPackets().handleItemToClient(second));
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); //Trade disabled
|
||||||
|
wrapper.passthrough(Type.INT); //Number of tools uses
|
||||||
|
wrapper.passthrough(Type.INT); //Maximum number of trade uses
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String oldChannel = InventoryPackets.getOldPluginChannelId(channel);
|
||||||
|
if (oldChannel == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find old channel for " + channel);
|
||||||
|
wrapper.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wrapper.write(Type.STRING, oldChannel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Particle
|
||||||
|
protocol.out(State.PLAY, 0x24, 0x22, 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 {
|
||||||
|
Particle particle = new Particle(wrapper.get(Type.INT, 0));
|
||||||
|
|
||||||
|
ParticleMapping.ParticleData old = ParticleMapping.getMapping(particle.getId());
|
||||||
|
|
||||||
|
wrapper.set(Type.INT, 0, old.getHistoryId());
|
||||||
|
|
||||||
|
for (int i : old.rewriteData(protocol, wrapper))
|
||||||
|
wrapper.write(Type.VAR_INT, i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Player List Item
|
||||||
|
protocol.out(State.PLAY, 0x30, 0x2E, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||||
|
TabCompleteStorage storage = packetWrapper.user().get(TabCompleteStorage.class);
|
||||||
|
int action = packetWrapper.passthrough(Type.VAR_INT);
|
||||||
|
int nPlayers = packetWrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int i = 0; i < nPlayers; i++) {
|
||||||
|
UUID uuid = packetWrapper.passthrough(Type.UUID);
|
||||||
|
if (action == 0) { // Add
|
||||||
|
String name = packetWrapper.passthrough(Type.STRING);
|
||||||
|
storage.usernames.put(uuid, name);
|
||||||
|
int nProperties = packetWrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int j = 0; j < nProperties; j++) {
|
||||||
|
packetWrapper.passthrough(Type.STRING);
|
||||||
|
packetWrapper.passthrough(Type.STRING);
|
||||||
|
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||||
|
packetWrapper.passthrough(Type.STRING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
packetWrapper.passthrough(Type.VAR_INT);
|
||||||
|
packetWrapper.passthrough(Type.VAR_INT);
|
||||||
|
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||||
|
packetWrapper.passthrough(Type.STRING);
|
||||||
|
}
|
||||||
|
} else if (action == 1) { // Update Game Mode
|
||||||
|
packetWrapper.passthrough(Type.VAR_INT);
|
||||||
|
} else if (action == 2) { // Update Ping
|
||||||
|
packetWrapper.passthrough(Type.VAR_INT);
|
||||||
|
} else if (action == 3) { // Update Display Name
|
||||||
|
if (packetWrapper.passthrough(Type.BOOLEAN)) {
|
||||||
|
packetWrapper.passthrough(Type.STRING);
|
||||||
|
}
|
||||||
|
} else if (action == 4) { // Remove Player
|
||||||
|
storage.usernames.remove(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Scoreboard Objective
|
||||||
|
protocol.out(State.PLAY, 0x45, 0x42, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.STRING);
|
||||||
|
map(Type.BYTE);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
byte mode = wrapper.get(Type.BYTE, 0);
|
||||||
|
if (mode == 0 || mode == 2) {
|
||||||
|
String value = wrapper.read(Type.STRING);
|
||||||
|
value = ChatRewriter.jsonTextToLegacy(value);
|
||||||
|
if (value.length() > 32) value = value.substring(0, 32);
|
||||||
|
wrapper.write(Type.STRING, value);
|
||||||
|
int type = wrapper.read(Type.VAR_INT);
|
||||||
|
wrapper.write(Type.STRING, type == 1 ? "hearts" : "integer");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Teams
|
||||||
|
protocol.out(State.PLAY, 0x47, 0x44, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.STRING);
|
||||||
|
map(Type.BYTE);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
byte action = wrapper.get(Type.BYTE, 0);
|
||||||
|
if (action == 0 || action == 2) {
|
||||||
|
String displayName = wrapper.read(Type.STRING);
|
||||||
|
displayName = ChatRewriter.jsonTextToLegacy(displayName);
|
||||||
|
displayName = ChatUtil.removeUnusedColor(displayName, 'f');
|
||||||
|
if (displayName.length() > 32) displayName = displayName.substring(0, 32);
|
||||||
|
wrapper.write(Type.STRING, displayName);
|
||||||
|
|
||||||
|
byte flags = wrapper.read(Type.BYTE);
|
||||||
|
String nameTagVisibility = wrapper.read(Type.STRING);
|
||||||
|
String collisionRule = wrapper.read(Type.STRING);
|
||||||
|
|
||||||
|
int colour = wrapper.read(Type.VAR_INT);
|
||||||
|
if (colour == 21) {
|
||||||
|
colour = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO team color/prefix handling changed from 1.12.2 to 1.13 and to 1.13.1 again afaik
|
||||||
|
String prefix = wrapper.read(Type.STRING);
|
||||||
|
String suffix = wrapper.read(Type.STRING);
|
||||||
|
prefix = prefix == null || prefix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(prefix);
|
||||||
|
prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r");
|
||||||
|
prefix = ChatUtil.removeUnusedColor(prefix, 'f', true);
|
||||||
|
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
||||||
|
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||||
|
suffix = suffix == null || suffix.equals("null") ? "" : ChatRewriter.jsonTextToLegacy(suffix);
|
||||||
|
suffix = ChatUtil.removeUnusedColor(suffix, 'f');
|
||||||
|
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||||
|
wrapper.write(Type.STRING, prefix);
|
||||||
|
wrapper.write(Type.STRING, suffix);
|
||||||
|
|
||||||
|
wrapper.write(Type.BYTE, flags);
|
||||||
|
wrapper.write(Type.STRING, nameTagVisibility);
|
||||||
|
wrapper.write(Type.STRING, collisionRule);
|
||||||
|
|
||||||
|
wrapper.write(Type.BYTE, (byte) colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action == 0 || action == 3 || action == 4) {
|
||||||
|
wrapper.passthrough(Type.STRING_ARRAY); //Entities
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tab-Complete (clientbound) TODO MODIFIED
|
||||||
|
protocol.out(State.PLAY, 0x10, 0x0E, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||||
|
if (storage.lastRequest == null) {
|
||||||
|
wrapper.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (storage.lastId != wrapper.read(Type.VAR_INT)) wrapper.cancel();
|
||||||
|
int start = wrapper.read(Type.VAR_INT);
|
||||||
|
int length = wrapper.read(Type.VAR_INT);
|
||||||
|
|
||||||
|
int lastRequestPartIndex = storage.lastRequest.lastIndexOf(' ') + 1;
|
||||||
|
if (lastRequestPartIndex != start) wrapper.cancel(); // Client only replaces after space
|
||||||
|
|
||||||
|
if (length != storage.lastRequest.length() - lastRequestPartIndex) {
|
||||||
|
wrapper.cancel(); // We can't set the length in previous versions
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
String match = wrapper.read(Type.STRING);
|
||||||
|
wrapper.write(Type.STRING, (start == 0 && !storage.lastAssumeCommand ? "/" : "") + match);
|
||||||
|
// Ignore tooltip
|
||||||
|
if (wrapper.read(Type.BOOLEAN)) {
|
||||||
|
wrapper.read(Type.STRING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tab-Complete (serverbound)
|
||||||
|
protocol.in(State.PLAY, 0x05, 0x01, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||||
|
int id = ThreadLocalRandom.current().nextInt();
|
||||||
|
wrapper.write(Type.VAR_INT, id);
|
||||||
|
|
||||||
|
String command = wrapper.read(Type.STRING);
|
||||||
|
boolean assumeCommand = wrapper.read(Type.BOOLEAN);
|
||||||
|
wrapper.read(Type.OPTIONAL_POSITION);
|
||||||
|
|
||||||
|
if (!assumeCommand) {
|
||||||
|
if (command.startsWith("/")) {
|
||||||
|
command = command.substring(1);
|
||||||
|
} else {
|
||||||
|
wrapper.cancel();
|
||||||
|
PacketWrapper response = wrapper.create(0xE);
|
||||||
|
List<String> usernames = new ArrayList<>();
|
||||||
|
for (String value : storage.usernames.values()) {
|
||||||
|
if (value.toLowerCase().startsWith(command.substring(command.lastIndexOf(' ') + 1).toLowerCase())) {
|
||||||
|
usernames.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.write(Type.VAR_INT, usernames.size());
|
||||||
|
for (String value : usernames) {
|
||||||
|
response.write(Type.STRING, value);
|
||||||
|
}
|
||||||
|
response.send(protocol.getClass());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.write(Type.STRING, command);
|
||||||
|
storage.lastId = id;
|
||||||
|
storage.lastAssumeCommand = assumeCommand;
|
||||||
|
storage.lastRequest = command;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Plugin Message
|
||||||
|
protocol.in(State.PLAY, 0x0A, 0x09, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
String channel = wrapper.read(Type.STRING);
|
||||||
|
if (channel.equals("MC|BSign") || channel.equals("MC|BEdit")) {
|
||||||
|
wrapper.setId(0x0B);
|
||||||
|
Item book = wrapper.read(Type.ITEM);
|
||||||
|
wrapper.write(Type.FLAT_ITEM, getProtocol().getBlockItemPackets().handleItemToServer(book));
|
||||||
|
boolean signing = channel.equals("MC|BSign");
|
||||||
|
wrapper.write(Type.BOOLEAN, signing);
|
||||||
|
} else if (channel.equals("MC|ItemName")) {
|
||||||
|
wrapper.setId(0x1C);
|
||||||
|
} else if (channel.equals("MC|AdvCmd")) {
|
||||||
|
byte type = wrapper.read(Type.BYTE);
|
||||||
|
if (type == 0) {
|
||||||
|
//Information from https://wiki.vg/index.php?title=Plugin_channels&oldid=14089
|
||||||
|
//The Notchain client only uses this for command block minecarts and uses MC|AutoCmd for blocks, but the Notchian server still accepts it for either.
|
||||||
|
//Maybe older versions used this and we need to implement this? The issues is that we would have to save the command block types
|
||||||
|
wrapper.setId(0x22);
|
||||||
|
wrapper.cancel();
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Client send MC|AdvCmd custom payload to update command block, weird!");
|
||||||
|
} else if (type == 1) {
|
||||||
|
wrapper.setId(0x23);
|
||||||
|
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Entity Id
|
||||||
|
wrapper.passthrough(Type.STRING); //Command
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); //Track Output
|
||||||
|
|
||||||
|
} else {
|
||||||
|
wrapper.cancel();
|
||||||
|
}
|
||||||
|
} else if (channel.equals("MC|AutoCmd")) {
|
||||||
|
wrapper.setId(0x22);
|
||||||
|
|
||||||
|
Integer x = wrapper.read(Type.INT);
|
||||||
|
Integer y = wrapper.read(Type.INT);
|
||||||
|
Integer z = wrapper.read(Type.INT);
|
||||||
|
|
||||||
|
wrapper.write(Type.POSITION, new Position(x.longValue(), y.longValue(), z.longValue()));
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.STRING); //Command
|
||||||
|
|
||||||
|
byte flags = 0;
|
||||||
|
if (wrapper.read(Type.BOOLEAN)) flags |= 0x01; //Track Output
|
||||||
|
|
||||||
|
String mode = wrapper.read(Type.STRING);
|
||||||
|
|
||||||
|
int modeId = mode.equals("SEQUENCE") ? 0 : mode.equals("AUTO") ? 1 : 2;
|
||||||
|
wrapper.write(Type.VAR_INT, modeId);
|
||||||
|
|
||||||
|
if (wrapper.read(Type.BOOLEAN)) flags |= 0x02; //Is conditional
|
||||||
|
if (wrapper.read(Type.BOOLEAN)) flags |= 0x04; //Automatic
|
||||||
|
|
||||||
|
wrapper.write(Type.BYTE, flags);
|
||||||
|
} else if (channel.equals("MC|Struct")) {
|
||||||
|
wrapper.setId(0x25);
|
||||||
|
Integer x = wrapper.read(Type.INT);
|
||||||
|
Integer y = wrapper.read(Type.INT);
|
||||||
|
Integer z = wrapper.read(Type.INT);
|
||||||
|
wrapper.write(Type.POSITION, new Position(x.longValue(), y.longValue(), z.longValue()));
|
||||||
|
wrapper.write(Type.VAR_INT, wrapper.read(Type.BYTE) - 1);
|
||||||
|
String mode = wrapper.read(Type.STRING);
|
||||||
|
int modeId = mode.equals("SAVE") ? 0 : mode.equals("LOAD") ? 1 : mode.equals("CORNER") ? 2 : 3;
|
||||||
|
wrapper.write(Type.VAR_INT, modeId);
|
||||||
|
wrapper.passthrough(Type.STRING); //Name
|
||||||
|
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset X
|
||||||
|
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset Y
|
||||||
|
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Offset Z
|
||||||
|
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size X
|
||||||
|
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size Y
|
||||||
|
wrapper.write(Type.BYTE, wrapper.read(Type.INT).byteValue()); //Size Z
|
||||||
|
String mirror = wrapper.read(Type.STRING);
|
||||||
|
int mirrorId = mode.equals("NONE") ? 0 : mode.equals("LEFT_RIGHT") ? 1 : 2;
|
||||||
|
String rotation = wrapper.read(Type.STRING);
|
||||||
|
int rotationId = mode.equals("NONE") ? 0 : mode.equals("CLOCKWISE_90") ? 1 : mode.equals("CLOCKWISE_180") ? 2 : 3;
|
||||||
|
wrapper.passthrough(Type.STRING); //Metadata
|
||||||
|
byte flags = 0;
|
||||||
|
if (wrapper.read(Type.BOOLEAN)) flags |= 0x01; //Ignore entities
|
||||||
|
if (wrapper.read(Type.BOOLEAN)) flags |= 0x02; //Show air
|
||||||
|
if (wrapper.read(Type.BOOLEAN)) flags |= 0x04; //Show bounding box
|
||||||
|
wrapper.passthrough(Type.FLOAT); //Integrity
|
||||||
|
wrapper.passthrough(Type.VAR_LONG); //Seed
|
||||||
|
wrapper.write(Type.BYTE, flags);
|
||||||
|
} else if (channel.equals("MC|Beacon")) {
|
||||||
|
wrapper.setId(0x20);
|
||||||
|
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Primary Effect
|
||||||
|
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Secondary Effect
|
||||||
|
} else if (channel.equals("MC|TrSel")) {
|
||||||
|
wrapper.setId(0x1F);
|
||||||
|
wrapper.write(Type.VAR_INT, wrapper.read(Type.INT)); //Slot
|
||||||
|
} else if (channel.equals("MC|PickItem")) {
|
||||||
|
wrapper.setId(0x15);
|
||||||
|
} else {
|
||||||
|
String newChannel = InventoryPackets.getNewPluginChannelId(channel);
|
||||||
|
if (newChannel == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find new channel for " + channel);
|
||||||
|
wrapper.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wrapper.write(Type.STRING, newChannel);
|
||||||
|
//TODO REGISTER and UNREGISTER (see ViaVersion)
|
||||||
|
wrapper.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.NamedSoundMapping;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.SoundMapping;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class SoundPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||||
|
private static final String[] SOUND_SOURCES = {"master", "music", "record", "weather", "block", "hostile", "neutral", "player", "ambient", "voice"};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_12_2To1_13 protocol) {
|
||||||
|
|
||||||
|
//Named Sound Event
|
||||||
|
protocol.out(State.PLAY, 0x1A, 0x19, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.STRING);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
String newSound = wrapper.get(Type.STRING, 0);
|
||||||
|
String oldSound = NamedSoundMapping.getOldId(newSound);
|
||||||
|
if (oldSound != null) {
|
||||||
|
wrapper.set(Type.STRING, 0, oldSound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Stop Sound
|
||||||
|
protocol.out(State.PLAY, 0x4C, 0x18, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.write(Type.STRING, "MC|StopSound");
|
||||||
|
byte flags = wrapper.read(Type.BYTE);
|
||||||
|
String source;
|
||||||
|
if ((flags & 0x01) != 0) {
|
||||||
|
source = SOUND_SOURCES[wrapper.read(Type.VAR_INT)];
|
||||||
|
} else {
|
||||||
|
source = "";
|
||||||
|
}
|
||||||
|
String sound = (flags & 0x02) != 0 ? wrapper.read(Type.STRING) : "";
|
||||||
|
|
||||||
|
wrapper.write(Type.STRING, source);
|
||||||
|
wrapper.write(Type.STRING, sound);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Sound Effect
|
||||||
|
protocol.out(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int newSound = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
int oldSound = SoundMapping.getOldSound(newSound);
|
||||||
|
if (oldSound == -1) {
|
||||||
|
wrapper.cancel();
|
||||||
|
} else {
|
||||||
|
wrapper.set(Type.VAR_INT, 0, oldSound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.*;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
import us.myles.ViaVersion.api.platform.providers.Provider;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class BackwardsBlockEntityProvider implements Provider {
|
||||||
|
private final Map<String, BackwardsBlockEntityProvider.BackwardsBlockEntityHandler> handlers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public BackwardsBlockEntityProvider() {
|
||||||
|
handlers.put("minecraft:flower_pot", new FlowerPotHandler()); // TODO requires special treatment, manually send
|
||||||
|
handlers.put("minecraft:bed", new BedHandler());
|
||||||
|
handlers.put("minecraft:banner", new BannerHandler());
|
||||||
|
handlers.put("minecraft:skull", new SkullHandler());
|
||||||
|
handlers.put("minecraft:mob_spawner", new SpawnerHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a block entity handler is present
|
||||||
|
*
|
||||||
|
* @param key Id of the NBT data ex: minecraft:bed
|
||||||
|
* @return true if present
|
||||||
|
*/
|
||||||
|
public boolean isHandled(String key) {
|
||||||
|
return handlers.containsKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform blocks to block entities!
|
||||||
|
*
|
||||||
|
* @param user The user
|
||||||
|
* @param position The position of the block entity
|
||||||
|
* @param tag The block entity tag
|
||||||
|
*/
|
||||||
|
public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception {
|
||||||
|
String id = (String) tag.get("id").getValue();
|
||||||
|
BackwardsBlockEntityHandler handler = handlers.get(id);
|
||||||
|
if (handler == null) {
|
||||||
|
if (Via.getManager().isDebug()) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag);
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
BackwardsBlockStorage storage = user.get(BackwardsBlockStorage.class);
|
||||||
|
|
||||||
|
if (!storage.contains(position)) {
|
||||||
|
if (Via.getManager().isDebug()) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Handled BlockEntity does not have a stored block :( " + id + " full tag: " + tag);
|
||||||
|
}
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
return handler.transform(user, storage.get(position), tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform blocks to block entities!
|
||||||
|
*
|
||||||
|
* @param user The user
|
||||||
|
* @param position The position of the block entity
|
||||||
|
* @param id The block entity id
|
||||||
|
*/
|
||||||
|
public CompoundTag transform(UserConnection user, Position position, String id) throws Exception {
|
||||||
|
CompoundTag tag = new CompoundTag("");
|
||||||
|
tag.put(new StringTag("id", id));
|
||||||
|
tag.put(new IntTag("x", Math.toIntExact(position.getX())));
|
||||||
|
tag.put(new IntTag("y", Math.toIntExact(position.getY())));
|
||||||
|
tag.put(new IntTag("z", Math.toIntExact(position.getZ())));
|
||||||
|
|
||||||
|
return this.transform(user, position, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface BackwardsBlockEntityHandler {
|
||||||
|
CompoundTag transform(UserConnection user, int blockId, CompoundTag tag);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class BackwardsBlockStorage extends StoredObject {
|
||||||
|
// This BlockStorage is very exclusive (;
|
||||||
|
private static final Set<Integer> whitelist = Sets.newConcurrentHashSet();
|
||||||
|
|
||||||
|
static {
|
||||||
|
// Flower pots
|
||||||
|
for (int i = 5265; i <= 5286; i++)
|
||||||
|
whitelist.add(i);
|
||||||
|
|
||||||
|
// Add those beds
|
||||||
|
for (int i = 0; i < (16 * 16); i++)
|
||||||
|
whitelist.add(748 + i);
|
||||||
|
|
||||||
|
// Add the banners
|
||||||
|
for (int i = 6854; i <= 7173; i++)
|
||||||
|
whitelist.add(i);
|
||||||
|
|
||||||
|
// Spawner
|
||||||
|
whitelist.add(1647);
|
||||||
|
|
||||||
|
// Skulls
|
||||||
|
for (int i = 5447; i <= 5566; i++)
|
||||||
|
whitelist.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Map<Position, Integer> blocks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public BackwardsBlockStorage(UserConnection user) {
|
||||||
|
super(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void checkAndStore(Position position, int block) {
|
||||||
|
if (!whitelist.contains(block)) {
|
||||||
|
// Remove if not whitelisted
|
||||||
|
if (blocks.containsKey(position))
|
||||||
|
blocks.remove(position);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
blocks.put(position, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWelcome(int block) {
|
||||||
|
return whitelist.contains(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Position position) {
|
||||||
|
return blocks.containsKey(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int get(Position position) {
|
||||||
|
return blocks.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int remove(Position position) {
|
||||||
|
return blocks.remove(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class TabCompleteStorage extends StoredObject {
|
||||||
|
public int lastId;
|
||||||
|
public String lastRequest;
|
||||||
|
public boolean lastAssumeCommand;
|
||||||
|
public Map<UUID, String> usernames = new HashMap<>();
|
||||||
|
|
||||||
|
public TabCompleteStorage(UserConnection user) {
|
||||||
|
super(user);
|
||||||
|
}
|
||||||
|
}
|
@ -96,7 +96,7 @@ public class Protocol1_12To1_12_1 extends BackwardsProtocol {
|
|||||||
registerIncoming(State.PLAY, 0xf, 0x10);
|
registerIncoming(State.PLAY, 0xf, 0x10);
|
||||||
registerIncoming(State.PLAY, 0x10, 0x11);
|
registerIncoming(State.PLAY, 0x10, 0x11);
|
||||||
registerIncoming(State.PLAY, 0x11, 0x12);
|
registerIncoming(State.PLAY, 0x11, 0x12);
|
||||||
registerIncoming(State.PLAY, 0x12, -1); // No sent by client, sad :(
|
// New incoming 0x12 - No sent by client, sad :(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.EntityPackets1_13_2;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.InventoryPackets1_13_2;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets.WorldPackets1_13_2;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class Protocol1_13_1To1_13_2 extends BackwardsProtocol {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets() {
|
||||||
|
InventoryPackets1_13_2.register(this);
|
||||||
|
WorldPackets1_13_2.register(this);
|
||||||
|
EntityPackets1_13_2.register(this);
|
||||||
|
|
||||||
|
//Edit Book
|
||||||
|
registerIncoming(State.PLAY, 0x0B, 0x0B, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Advancements
|
||||||
|
registerOutgoing(State.PLAY, 0x51, 0x51, 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
|
||||||
|
Item icon = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
wrapper.write(Type.FLAT_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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(UserConnection userConnection) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.packets;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
|
||||||
|
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_13;
|
||||||
|
import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
|
||||||
|
public class EntityPackets1_13_2 {
|
||||||
|
|
||||||
|
|
||||||
|
public static void register(Protocol protocol) {
|
||||||
|
// Spawn mob packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
|
map(Type.DOUBLE); // 3 - X
|
||||||
|
map(Type.DOUBLE); // 4 - Y
|
||||||
|
map(Type.DOUBLE); // 5 - Z
|
||||||
|
map(Type.BYTE); // 6 - Yaw
|
||||||
|
map(Type.BYTE); // 7 - Pitch
|
||||||
|
map(Type.BYTE); // 8 - Head Pitch
|
||||||
|
map(Type.SHORT); // 9 - Velocity X
|
||||||
|
map(Type.SHORT); // 10 - Velocity Y
|
||||||
|
map(Type.SHORT); // 11 - Velocity Z
|
||||||
|
map(Types1_13_2.METADATA_LIST, Types1_13.METADATA_LIST); // 12 - Metadata
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||||
|
if (metadata.getMetaType() == MetaType1_13_2.Slot) {
|
||||||
|
metadata.setMetaType(MetaType1_13.Slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn player packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Player UUID
|
||||||
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
map(Type.DOUBLE); // 3 - Y
|
||||||
|
map(Type.DOUBLE); // 4 - Z
|
||||||
|
map(Type.BYTE); // 5 - Yaw
|
||||||
|
map(Type.BYTE); // 6 - Pitch
|
||||||
|
map(Types1_13_2.METADATA_LIST, Types1_13.METADATA_LIST); // 7 - Metadata
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||||
|
if (metadata.getMetaType() == MetaType1_13_2.Slot) {
|
||||||
|
metadata.setMetaType(MetaType1_13.Slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Metadata packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Types1_13_2.METADATA_LIST, Types1_13.METADATA_LIST); // 1 - Metadata list
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (Metadata metadata : wrapper.get(Types1_13.METADATA_LIST, 0)) {
|
||||||
|
if (metadata.getMetaType() == MetaType1_13_2.Slot) {
|
||||||
|
metadata.setMetaType(MetaType1_13.Slot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,151 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.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;
|
||||||
|
|
||||||
|
public class InventoryPackets1_13_2 {
|
||||||
|
|
||||||
|
public static void register(Protocol protocol) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Outgoing packets
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Set slot packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x17, 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, Type.FLAT_ITEM); // 2 - Slot Value
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Window items packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
|
map(Type.FLAT_VAR_INT_ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Plugin message
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.STRING); // Channel
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
String channel = wrapper.get(Type.STRING, 0);
|
||||||
|
if (channel.equals("minecraft:trader_list") || channel.equals("trader_list")) {
|
||||||
|
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||||
|
|
||||||
|
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
// Input Item
|
||||||
|
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
// Output Item
|
||||||
|
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
|
||||||
|
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||||
|
if (secondItem) {
|
||||||
|
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||||
|
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||||
|
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Entity Equipment Packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, 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, Type.FLAT_ITEM); // 2 - Item
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Declare Recipes
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x54, 0x54, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int recipesNo = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int i = 0; i < recipesNo; i++) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Id
|
||||||
|
String type = wrapper.passthrough(Type.STRING);
|
||||||
|
if (type.equals("crafting_shapeless")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||||
|
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
} else if (type.equals("crafting_shaped")) {
|
||||||
|
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
for (int i1 = 0; i1 < ingredientsNo; i1++) {
|
||||||
|
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
} else if (type.equals("smelting")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
// Ingredient start
|
||||||
|
wrapper.write(Type.FLAT_ITEM_ARRAY_VAR_INT, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
|
||||||
|
// Ingredient end
|
||||||
|
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
wrapper.passthrough(Type.FLOAT); // EXP
|
||||||
|
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Incoming packets
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Click window packet
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x08, 0x08, 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_ITEM, Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Creative Inventory Action
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.SHORT); // 0 - Slot
|
||||||
|
map(Type.FLAT_ITEM, Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.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;
|
||||||
|
|
||||||
|
public class WorldPackets1_13_2 {
|
||||||
|
|
||||||
|
public static void register(Protocol protocol) {
|
||||||
|
//spawn particle
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x24, 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) {
|
||||||
|
wrapper.write(Type.FLAT_ITEM, wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,354 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.BackwardsMappings;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.SoundMapping;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.BlockItemPackets1_14;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPackets1_14;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Protocol1_13_2To1_14 extends BackwardsProtocol {
|
||||||
|
private BlockItemPackets1_14 blockItemPackets;
|
||||||
|
private EntityPackets1_14 entityPackets;
|
||||||
|
|
||||||
|
static {
|
||||||
|
BackwardsMappings.init();
|
||||||
|
SoundMapping.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets() {
|
||||||
|
blockItemPackets = new BlockItemPackets1_14();
|
||||||
|
blockItemPackets.register(this);
|
||||||
|
entityPackets = new EntityPackets1_14();
|
||||||
|
entityPackets.register(this);
|
||||||
|
new PlayerPackets1_14().register(this);
|
||||||
|
new SoundPackets1_14().register(this);
|
||||||
|
|
||||||
|
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, 0x54, 0x1D);
|
||||||
|
registerOutgoing(State.PLAY, 0x1C, 0x1E);
|
||||||
|
registerOutgoing(State.PLAY, 0x1E, 0x20);
|
||||||
|
registerOutgoing(State.PLAY, 0x20, 0x21);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x2B, 0x27);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x2C, 0x2B);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x30, 0x2D);
|
||||||
|
registerOutgoing(State.PLAY, 0x31, 0x2E);
|
||||||
|
registerOutgoing(State.PLAY, 0x32, 0x2F);
|
||||||
|
registerOutgoing(State.PLAY, 0x33, 0x30);
|
||||||
|
registerOutgoing(State.PLAY, 0x34, 0x31);
|
||||||
|
// Position and look
|
||||||
|
registerOutgoing(State.PLAY, 0x35, 0x32);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x36, 0x34);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x38, 0x36);
|
||||||
|
registerOutgoing(State.PLAY, 0x39, 0x37);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x3B, 0x39);
|
||||||
|
registerOutgoing(State.PLAY, 0x3C, 0x3A);
|
||||||
|
registerOutgoing(State.PLAY, 0x3D, 0x3B);
|
||||||
|
registerOutgoing(State.PLAY, 0x3E, 0x3C);
|
||||||
|
registerOutgoing(State.PLAY, 0x3F, 0x3D);
|
||||||
|
registerOutgoing(State.PLAY, 0x42, 0x3E);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x44, 0x40);
|
||||||
|
registerOutgoing(State.PLAY, 0x45, 0x41);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x47, 0x43);
|
||||||
|
registerOutgoing(State.PLAY, 0x48, 0x44);
|
||||||
|
registerOutgoing(State.PLAY, 0x49, 0x45);
|
||||||
|
registerOutgoing(State.PLAY, 0x4A, 0x46);
|
||||||
|
registerOutgoing(State.PLAY, 0x4B, 0x47);
|
||||||
|
registerOutgoing(State.PLAY, 0x4C, 0x48);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x4E, 0x4A);
|
||||||
|
registerOutgoing(State.PLAY, 0x4F, 0x4B);
|
||||||
|
registerOutgoing(State.PLAY, 0x52, 0x4C);
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x53, 0x4E); // c
|
||||||
|
registerOutgoing(State.PLAY, 0x55, 0x4F); // c
|
||||||
|
registerOutgoing(State.PLAY, 0x56, 0x50); // c
|
||||||
|
|
||||||
|
//Update View Position
|
||||||
|
registerOutgoing(State.PLAY, 0x40, -1, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||||
|
packetWrapper.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//Update View Distance
|
||||||
|
registerOutgoing(State.PLAY, 0x41, -1, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper packetWrapper) throws Exception {
|
||||||
|
packetWrapper.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x57, 0x51, new PacketRemapper() { // c
|
||||||
|
@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
|
||||||
|
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
|
||||||
|
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||||
|
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||||
|
if ((flags & 1) != 0)
|
||||||
|
wrapper.passthrough(Type.STRING); // Background texture
|
||||||
|
wrapper.passthrough(Type.FLOAT); // X
|
||||||
|
wrapper.passthrough(Type.FLOAT); // Y
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
|
||||||
|
|
||||||
|
int arrayLength = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int array = 0; array < arrayLength; array++) {
|
||||||
|
wrapper.passthrough(Type.STRING_ARRAY); // String array
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
registerOutgoing(State.PLAY, 0x58, 0x52); // c
|
||||||
|
registerOutgoing(State.PLAY, 0x59, 0x53); // c
|
||||||
|
|
||||||
|
// tags
|
||||||
|
registerOutgoing(State.PLAY, 0x5B, 0x55, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() { // c
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int blockTagsSize = wrapper.read(Type.VAR_INT);
|
||||||
|
wrapper.write(Type.VAR_INT, blockTagsSize); // block tags
|
||||||
|
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] = getNewBlockStateId(blockIds[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int itemTagsSize = wrapper.read(Type.VAR_INT);
|
||||||
|
wrapper.write(Type.VAR_INT, itemTagsSize); // item tags
|
||||||
|
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] = /*BlockItemPackets1_14.getNewItemId TODO BLOCK IDS*/(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);
|
||||||
|
}
|
||||||
|
// Eat entity tags
|
||||||
|
int entityTagsSize = wrapper.read(Type.VAR_INT);
|
||||||
|
for (int i = 0; i < entityTagsSize; i++) {
|
||||||
|
wrapper.read(Type.STRING);
|
||||||
|
wrapper.read(Type.VAR_INT_ARRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Light update
|
||||||
|
out(State.PLAY, 0x24, -1, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int x = wrapper.read(Type.VAR_INT);
|
||||||
|
int z = wrapper.read(Type.VAR_INT);
|
||||||
|
int skyLightMask = wrapper.read(Type.VAR_INT);
|
||||||
|
int blockLightMask = wrapper.read(Type.VAR_INT);
|
||||||
|
int emptySkyLightMask = wrapper.read(Type.VAR_INT);
|
||||||
|
int emptyBlockLightMask = wrapper.read(Type.VAR_INT);
|
||||||
|
|
||||||
|
byte[][] skyLight = new byte[16][];
|
||||||
|
// we don't need void and +256 light
|
||||||
|
if (isSet(skyLightMask, 0)) {
|
||||||
|
wrapper.read(Type.BYTE_ARRAY);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
if (isSet(skyLightMask, i + 1)) {
|
||||||
|
Byte[] array = wrapper.read(Type.BYTE_ARRAY);
|
||||||
|
skyLight[i] = new byte[array.length];
|
||||||
|
for (int j = 0; j < array.length; j++) {
|
||||||
|
skyLight[i][j] = array[j];
|
||||||
|
}
|
||||||
|
} else if (isSet(emptySkyLightMask, i + 1)) {
|
||||||
|
skyLight[i] = ChunkLightStorage.EMPTY_LIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isSet(skyLightMask, 17)) {
|
||||||
|
wrapper.read(Type.BYTE_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[][] blockLight = new byte[16][];
|
||||||
|
if (isSet(blockLightMask, 0)) {
|
||||||
|
wrapper.read(Type.BYTE_ARRAY);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
if (isSet(blockLightMask, i + 1)) {
|
||||||
|
Byte[] array = wrapper.read(Type.BYTE_ARRAY);
|
||||||
|
blockLight[i] = new byte[array.length];
|
||||||
|
for (int j = 0; j < array.length; j++) {
|
||||||
|
blockLight[i][j] = array[j];
|
||||||
|
}
|
||||||
|
} else if (isSet(emptyBlockLightMask, i + 1)) {
|
||||||
|
blockLight[i] = ChunkLightStorage.EMPTY_LIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isSet(blockLightMask, 17)) {
|
||||||
|
wrapper.read(Type.BYTE_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.user().get(ChunkLightStorage.class).setStoredLight(skyLight, blockLight, x, z);
|
||||||
|
wrapper.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSet(int mask, int i) {
|
||||||
|
return (mask & (1 << i)) != 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//Incomming
|
||||||
|
|
||||||
|
//Unknown packet added in 19w11a - 0x02
|
||||||
|
registerIncoming(State.PLAY, 0x03, 0x02); // r
|
||||||
|
registerIncoming(State.PLAY, 0x04, 0x03); // r
|
||||||
|
registerIncoming(State.PLAY, 0x05, 0x04); // r
|
||||||
|
registerIncoming(State.PLAY, 0x06, 0x05); // r
|
||||||
|
registerIncoming(State.PLAY, 0x07, 0x06); // r
|
||||||
|
registerIncoming(State.PLAY, 0x08, 0x07); // r
|
||||||
|
|
||||||
|
registerIncoming(State.PLAY, 0x0A, 0x09); // r
|
||||||
|
registerIncoming(State.PLAY, 0x0B, 0x0A); // r
|
||||||
|
|
||||||
|
registerIncoming(State.PLAY, 0x0D, 0x0C); // r
|
||||||
|
registerIncoming(State.PLAY, 0x0E, 0x0D); // r
|
||||||
|
//Unknown packet added in 19w11a - 0x0F
|
||||||
|
registerIncoming(State.PLAY, 0x0F, 0x0E); // r
|
||||||
|
registerIncoming(State.PLAY, 0x11, 0x10); // r
|
||||||
|
registerIncoming(State.PLAY, 0x12, 0x11); // r
|
||||||
|
registerIncoming(State.PLAY, 0x13, 0x12); // r
|
||||||
|
registerIncoming(State.PLAY, 0x14, 0x0F); // r
|
||||||
|
registerIncoming(State.PLAY, 0x15, 0x13); // r
|
||||||
|
registerIncoming(State.PLAY, 0x16, 0x14); // r
|
||||||
|
registerIncoming(State.PLAY, 0x17, 0x15); // r
|
||||||
|
registerIncoming(State.PLAY, 0x18, 0x16); // r
|
||||||
|
registerIncoming(State.PLAY, 0x19, 0x17); // r
|
||||||
|
|
||||||
|
registerIncoming(State.PLAY, 0x1B, 0x19); // r
|
||||||
|
registerIncoming(State.PLAY, 0x1C, 0x1A); // r
|
||||||
|
|
||||||
|
registerIncoming(State.PLAY, 0x1E, 0x1C); // r
|
||||||
|
registerIncoming(State.PLAY, 0x1F, 0x1D); // r
|
||||||
|
registerIncoming(State.PLAY, 0x20, 0x1E); // r
|
||||||
|
registerIncoming(State.PLAY, 0x21, 0x1F); // r
|
||||||
|
registerIncoming(State.PLAY, 0x22, 0x20); // r
|
||||||
|
registerIncoming(State.PLAY, 0x23, 0x21); // r
|
||||||
|
|
||||||
|
registerIncoming(State.PLAY, 0x25, 0x23); // r
|
||||||
|
|
||||||
|
// registerIncoming(State.PLAY, 0x29, 0x27); // r
|
||||||
|
registerIncoming(State.PLAY, 0x2A, 0x27); // r
|
||||||
|
registerIncoming(State.PLAY, 0x2B, 0x28); // r
|
||||||
|
registerIncoming(State.PLAY, 0x2D, 0x2A); // r
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getNewBlockStateId(int id) {
|
||||||
|
int newId = BackwardsMappings.blockStateMappings.getNewBlock(id);
|
||||||
|
if (newId == -1) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 blockstate id for 1.13.2 block " + id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int getNewBlockId(int id) {
|
||||||
|
int newId = BackwardsMappings.blockMappings.getNewBlock(id);
|
||||||
|
if (newId == -1) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 block id for 1.13.2 block " + id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(UserConnection user) {
|
||||||
|
// Register ClientWorld
|
||||||
|
if (!user.has(ClientWorld.class))
|
||||||
|
user.put(new ClientWorld(user));
|
||||||
|
|
||||||
|
// Register EntityTracker if it doesn't exist yet.
|
||||||
|
if (!user.has(EntityTracker.class))
|
||||||
|
user.put(new EntityTracker(user));
|
||||||
|
|
||||||
|
// Init protocol in EntityTracker
|
||||||
|
user.get(EntityTracker.class).initProtocol(this);
|
||||||
|
|
||||||
|
if (!user.has(ChunkLightStorage.class))
|
||||||
|
user.put(new ChunkLightStorage(user));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||||
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonPrimitive;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class BackwardsMappings {
|
||||||
|
public static BlockMappings blockStateMappings;
|
||||||
|
public static BlockMappings blockMappings;
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
JsonObject mapping1_13_2 = MappingData.loadData("mapping-1.13.2.json");
|
||||||
|
JsonObject mapping1_14 = MappingData.loadData("mapping-1.14.json");
|
||||||
|
JsonObject mapping1_13_2to1_14 = loadData("mapping-1.13.2to1.14.json");
|
||||||
|
|
||||||
|
ViaBackwards.getPlatform().getLogger().info("Loading 1.14 -> 1.13.2 block mapping...");
|
||||||
|
blockStateMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blockstates"), mapping1_13_2.getAsJsonObject("blockstates"), mapping1_13_2to1_14.getAsJsonObject("blockstates"));
|
||||||
|
//blockMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void mapIdentifiers(short[] output, JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||||
|
for (Map.Entry<String, JsonElement> entry : newIdentifiers.entrySet()) {
|
||||||
|
String key = entry.getValue().getAsString();
|
||||||
|
Map.Entry<String, JsonElement> value = findValue(oldIdentifiers, key);
|
||||||
|
if (value == null) {
|
||||||
|
JsonPrimitive replacement = mapping.getAsJsonPrimitive(key);
|
||||||
|
if (replacement == null && key.contains("[")) {
|
||||||
|
replacement = mapping.getAsJsonPrimitive(key.substring(0, key.indexOf('[')));
|
||||||
|
}
|
||||||
|
if (replacement != null) {
|
||||||
|
if (replacement.getAsString().startsWith("id:")) {
|
||||||
|
String id = replacement.getAsString().replace("id:", "");
|
||||||
|
value = findValue(oldIdentifiers, oldIdentifiers.getAsJsonPrimitive(id).getAsString());
|
||||||
|
} else {
|
||||||
|
value = findValue(oldIdentifiers, replacement.getAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
|
||||||
|
if (replacement != null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + "/" + replacement.getAsString() + " :( ");
|
||||||
|
} else {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static Map.Entry<String, JsonElement> findValue(JsonObject object, String needle) {
|
||||||
|
for (Map.Entry<String, JsonElement> entry : object.entrySet()) {
|
||||||
|
String value = entry.getValue().getAsString();
|
||||||
|
if (value.equals(needle)) {
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static JsonObject loadData(String name) {
|
||||||
|
try (InputStreamReader reader = new InputStreamReader(BackwardsMappings.class.getClassLoader().getResourceAsStream("assets/viabackwards/data/" + name))) {
|
||||||
|
return GsonUtil.getGson().fromJson(reader, JsonObject.class);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface BlockMappings {
|
||||||
|
int getNewBlock(int old);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BlockMappingsShortArray implements BlockMappings {
|
||||||
|
private short[] oldToNew = new short[11270 + 1];
|
||||||
|
|
||||||
|
private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
|
||||||
|
Arrays.fill(oldToNew, (short) -1);
|
||||||
|
mapIdentifiers(oldToNew, newIdentifiers, oldIdentifiers, mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNewBlock(int old) {
|
||||||
|
return old >= 0 && old < oldToNew.length ? oldToNew[old] : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.EntityTypeRewriter;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class EntityTypeMapping {
|
||||||
|
private static Map<Integer, Integer> entityTypes = new HashMap<>();
|
||||||
|
private static Map<Integer, Integer> oldEntityToOldObject = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Field field = EntityTypeRewriter.class.getDeclaredField("entityTypes");
|
||||||
|
field.setAccessible(true);
|
||||||
|
Map<Integer, Integer> entityTypes = (Map<Integer, Integer>) field.get(null);
|
||||||
|
entityTypes.forEach((type1_12, type1_13) -> EntityTypeMapping.entityTypes.put(type1_13, type1_12));
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
for (Map.Entry<Integer, Integer> newToOld : entityTypes.entrySet()) {
|
||||||
|
Entity1_13Types.EntityType type1_13 = Entity1_13Types.getTypeFromId(newToOld.getValue(), false);
|
||||||
|
Entity1_13Types.ObjectTypes object1_13 = null;
|
||||||
|
for (Entity1_13Types.ObjectTypes objectType : Entity1_13Types.ObjectTypes.values()) {
|
||||||
|
if (objectType.getType() == type1_13) {
|
||||||
|
object1_13 = objectType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (object1_13 != null) {
|
||||||
|
oldEntityToOldObject.put(type1_13.getId(), object1_13.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Entity1_13Types.EntityType type : Entity1_13Types.EntityType.values()){
|
||||||
|
if(!entityTypes.containsValue(type.getId())){
|
||||||
|
entityTypes.put(type.getId(), type.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entityTypes.put(50, 48); // ocelot
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Integer> getOldId(int type1_14) {
|
||||||
|
return Optional.ofNullable(entityTypes.get(type1_14));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<Integer> getObjectId(int type1_13) {
|
||||||
|
return Optional.ofNullable(oldEntityToOldObject.get(type1_13));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
|
||||||
|
|
||||||
|
import us.myles.viaversion.libs.gson.JsonArray;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonElement;
|
||||||
|
import us.myles.viaversion.libs.gson.JsonObject;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
|
||||||
|
|
||||||
|
public class SoundMapping {
|
||||||
|
private static short[] sounds = new short[795];
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json");
|
||||||
|
JsonObject mapping1_14 = loadData("mapping-1.14.json");
|
||||||
|
|
||||||
|
Arrays.fill(sounds, (short) -1);
|
||||||
|
mapIdentifiers(sounds, mapping1_14.getAsJsonArray("sounds"), mapping1_13_2.getAsJsonArray("sounds"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
|
||||||
|
for (int i = 0; i < oldIdentifiers.size(); i++) {
|
||||||
|
JsonElement v = oldIdentifiers.get(i);
|
||||||
|
Integer index = findIndex(newIdentifiers, v.getAsString());
|
||||||
|
if (index == null) continue; //There will be missing sounds, since we are goind backwards
|
||||||
|
output[i] = index.shortValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Integer findIndex(JsonArray array, String value) {
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
JsonElement v = array.get(i);
|
||||||
|
if (v.getAsString().equals(value)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getOldSound(int newSound) {
|
||||||
|
return newSound >= sounds.length ? -1 : sounds[newSound];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,917 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_14;
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.Environment;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
|
||||||
|
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_13;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData;
|
||||||
|
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 us.myles.viaversion.libs.opennbt.conversion.ConverterRegistry;
|
||||||
|
import us.myles.viaversion.libs.opennbt.tag.builtin.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14> {
|
||||||
|
|
||||||
|
private static final String NBT_TAG_NAME = "ViaBackwards|" + Protocol1_13_2To1_14.class.getSimpleName();
|
||||||
|
private final Map<String, String> enchantmentMappings = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
|
||||||
|
// Open window
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x2E, 0x14, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() { // c
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int id = wrapper.read(Type.VAR_INT);
|
||||||
|
wrapper.write(Type.UNSIGNED_BYTE, (short) id);
|
||||||
|
int type = wrapper.read(Type.VAR_INT);
|
||||||
|
String stringType = null;
|
||||||
|
String title = null;
|
||||||
|
int slotSize = 0;
|
||||||
|
if (type < 6) {
|
||||||
|
if (type == 2) title = "Barrel";
|
||||||
|
stringType = "minecraft:container";
|
||||||
|
slotSize = (type + 1) * 9;
|
||||||
|
} else
|
||||||
|
switch (type) {
|
||||||
|
case 11:
|
||||||
|
stringType = "minecraft:crafting_table";
|
||||||
|
break;
|
||||||
|
case 9: //blast furnace
|
||||||
|
case 20: //smoker
|
||||||
|
case 13: //furnace
|
||||||
|
case 14: //grindstone
|
||||||
|
if (type == 9) title = "Blast Furnace";
|
||||||
|
if (type == 20) title = "Smoker";
|
||||||
|
if (type == 14) title = "Grindstone";
|
||||||
|
stringType = "minecraft:furnace";
|
||||||
|
slotSize = 3;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
stringType = "minecraft:dropper";
|
||||||
|
slotSize = 9;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
stringType = "minecraft:enchanting_table";
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
stringType = "minecraft:brewing_stand";
|
||||||
|
slotSize = 5;
|
||||||
|
break;
|
||||||
|
case 18:
|
||||||
|
stringType = "minecraft:villager";
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
stringType = "minecraft:beacon";
|
||||||
|
slotSize = 1;
|
||||||
|
break;
|
||||||
|
case 21: //cartography_table
|
||||||
|
case 7:
|
||||||
|
if (type == 21) title = "Cartography Table";
|
||||||
|
stringType = "minecraft:anvil";
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
stringType = "minecraft:hopper";
|
||||||
|
slotSize = 5;
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
stringType = "minecraft:shulker_box";
|
||||||
|
slotSize = 27;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stringType == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Can't open inventory for 1.13 player! Type: " + type);
|
||||||
|
wrapper.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.write(Type.STRING, stringType);
|
||||||
|
String t = wrapper.read(Type.STRING);
|
||||||
|
if (title != null) t = ChatRewriter.legacyTextToJson(title);
|
||||||
|
wrapper.write(Type.STRING, t);
|
||||||
|
wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Horse window
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x1F, 0x14, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() { // c
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.passthrough(Type.UNSIGNED_BYTE); // Window id
|
||||||
|
wrapper.write(Type.STRING, "EntityHorse"); // Type
|
||||||
|
wrapper.write(Type.STRING, "{\"translate\":\"minecraft.horse\"}"); // Title
|
||||||
|
wrapper.write(Type.UNSIGNED_BYTE, wrapper.read(Type.VAR_INT).shortValue()); // Number of slots
|
||||||
|
wrapper.passthrough(Type.INT); // Entity id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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 (int i = 0; i < stacks.length; i++) {
|
||||||
|
stacks[i] = handleItemToClient(stacks[i]);
|
||||||
|
}
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM_ARRAY, 0, stacks);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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 {
|
||||||
|
Item item = wrapper.get(Type.FLAT_VAR_INT_ITEM, 0);
|
||||||
|
item = handleItemToClient(item);
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Trade list
|
||||||
|
protocol.out(State.PLAY, 0x27, 0x19, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.write(Type.STRING, "minecraft:trader_list");
|
||||||
|
// wrapper.read(Type.STRING); // Remove channel
|
||||||
|
|
||||||
|
int windowId = wrapper.read(Type.VAR_INT);
|
||||||
|
wrapper.write(Type.INT, windowId);
|
||||||
|
|
||||||
|
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
// Input Item
|
||||||
|
Item input = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
input = handleItemToClient(input);
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, input);
|
||||||
|
|
||||||
|
|
||||||
|
// Output Item
|
||||||
|
Item output = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
output = handleItemToClient(output);
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, output);
|
||||||
|
|
||||||
|
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||||
|
if (secondItem) {
|
||||||
|
// Second Item
|
||||||
|
Item second = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
second = handleItemToClient(second);
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, 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.read(Type.INT);
|
||||||
|
wrapper.read(Type.INT);
|
||||||
|
wrapper.read(Type.FLOAT);
|
||||||
|
}
|
||||||
|
wrapper.read(Type.VAR_INT);
|
||||||
|
wrapper.read(Type.VAR_INT);
|
||||||
|
wrapper.read(Type.BOOLEAN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Book open
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x2D, 0x19, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.write(Type.STRING, "minecraft:book_open");
|
||||||
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Entity Equipment Packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x46, 0x42, 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 {
|
||||||
|
Item item = handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
AbstractEntityType entityType = wrapper.user().get(EntityTracker.class).get(getProtocol()).getEntityType(entityId);
|
||||||
|
if (entityType == null) return; // TODO: Check why there might (?) be an untracked entity
|
||||||
|
|
||||||
|
if (entityType.isOrHasParent(EntityType1_14.EntityType.ABSTRACT_HORSE)) {
|
||||||
|
wrapper.setId(0x3F);
|
||||||
|
wrapper.resetReader();
|
||||||
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
|
wrapper.read(Type.VAR_INT);
|
||||||
|
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
int armorType = item == null || item.getIdentifier() == 0 ? 0 : item.getIdentifier() - 726;
|
||||||
|
if (armorType < 0 || armorType > 3) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Received invalid horse armor: " + item);
|
||||||
|
wrapper.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Metadata> metadataList = new ArrayList<>();
|
||||||
|
metadataList.add(new Metadata(16, MetaType1_13_2.VarInt, armorType));
|
||||||
|
wrapper.write(Types1_13.METADATA_LIST, metadataList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting");
|
||||||
|
|
||||||
|
// Declare Recipes
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x5A, 0x54, new PacketRemapper() { // c
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
int deleted = 0;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
String type = wrapper.read(Type.STRING);
|
||||||
|
String id = wrapper.read(Type.STRING); // Recipe Identifier
|
||||||
|
type = type.replace("minecraft:", "");
|
||||||
|
if (removedTypes.contains(type)) {
|
||||||
|
switch (type) {
|
||||||
|
case "blasting":
|
||||||
|
case "smoking":
|
||||||
|
case "campfire_cooking":
|
||||||
|
wrapper.read(Type.STRING); // Group
|
||||||
|
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
wrapper.read(Type.FLOAT); // EXP
|
||||||
|
wrapper.read(Type.VAR_INT); // Cooking time
|
||||||
|
break;
|
||||||
|
case "stonecutting":
|
||||||
|
wrapper.read(Type.STRING); // Group?
|
||||||
|
wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
wrapper.read(Type.FLAT_VAR_INT_ITEM); // Result
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
deleted++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wrapper.write(Type.STRING, id);
|
||||||
|
wrapper.write(Type.STRING, type);
|
||||||
|
|
||||||
|
if (type.equals("crafting_shapeless")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int j = 0; j < ingredientsNo; j++) {
|
||||||
|
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
for (int k = 0; k < items.length; k++) {
|
||||||
|
items[k] = handleItemToClient(items[k]);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
|
||||||
|
}
|
||||||
|
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
|
||||||
|
} else if (type.equals("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.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
for (int k = 0; k < items.length; k++) {
|
||||||
|
items[k] = handleItemToClient(items[k]);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
|
||||||
|
}
|
||||||
|
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
|
||||||
|
} else if (type.equals("smelting")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
for (int k = 0; k < items.length; k++) {
|
||||||
|
items[k] = handleItemToClient(items[k]);
|
||||||
|
}
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
|
||||||
|
|
||||||
|
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.FLOAT); // EXP
|
||||||
|
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Incoming packets
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Click window packet
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x09, 0x08, 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 {
|
||||||
|
Item item = handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Creative Inventory Action
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x26, 0x24, 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 {
|
||||||
|
Item item = wrapper.get(Type.FLAT_VAR_INT_ITEM, 0);
|
||||||
|
item = handleItemToServer(item);
|
||||||
|
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Block break animation
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x08, 0x08, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
|
map(Type.BYTE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update block entity
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Block Action
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION1_14, Type.POSITION); // 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_13_2To1_14.getNewBlockStateId(wrapper.get(Type.VAR_INT, 0))); //TODO proper block id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Block Change
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0xB, 0xB, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
|
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_13_2To1_14.getNewBlockStateId(id));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Multi Block Change
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0xF, 0xF, 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_13_2To1_14.getNewBlockStateId(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Chunk
|
||||||
|
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_13Type(clientWorld), chunk);
|
||||||
|
|
||||||
|
ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ());
|
||||||
|
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||||
|
ChunkSection section = chunk.getSections()[i];
|
||||||
|
if (section == null) continue;
|
||||||
|
|
||||||
|
if (chunkLight == null) {
|
||||||
|
section.setBlockLight(ChunkLightStorage.FULL_LIGHT);
|
||||||
|
if (clientWorld.getEnvironment() == Environment.NORMAL) {
|
||||||
|
section.setSkyLight(ChunkLightStorage.FULL_LIGHT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
final byte[] blockLight = chunkLight.getBlockLight()[i];
|
||||||
|
section.setBlockLight(blockLight != null ? blockLight : ChunkLightStorage.FULL_LIGHT);
|
||||||
|
if (clientWorld.getEnvironment() == Environment.NORMAL) {
|
||||||
|
final byte[] skyLight = chunkLight.getSkyLight()[i];
|
||||||
|
section.setSkyLight(skyLight != null ? skyLight : ChunkLightStorage.FULL_LIGHT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||||
|
int old = section.getPaletteEntry(j);
|
||||||
|
int newId = Protocol1_13_2To1_14.getNewBlockStateId(old);
|
||||||
|
section.setPaletteEntry(j, newId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Unload chunk
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int x = wrapper.passthrough(Type.INT);
|
||||||
|
int z = wrapper.passthrough(Type.INT);
|
||||||
|
wrapper.user().get(ChunkLightStorage.class).unloadChunk(x, z);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Effect packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x22, 0x23, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // Effect Id
|
||||||
|
map(Type.POSITION1_14, Type.POSITION); // Location
|
||||||
|
map(Type.INT); // Data
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int id = wrapper.get(Type.INT, 0);
|
||||||
|
int data = wrapper.get(Type.INT, 1);
|
||||||
|
if (id == 1010) { // Play record
|
||||||
|
wrapper.set(Type.INT, 1, data = BlockItemPackets1_14.getNewItemId(data));
|
||||||
|
} else if (id == 2001) { // Block break + block break sound
|
||||||
|
wrapper.set(Type.INT, 1, data = Protocol1_14To1_13_2.getNewBlockStateId(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);
|
||||||
|
id = EntityPackets1_14.getOldParticleId(id);
|
||||||
|
if (id == 3 || id == 20) {
|
||||||
|
int data = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(data));
|
||||||
|
} else if (id == 27) {
|
||||||
|
Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
|
||||||
|
}
|
||||||
|
wrapper.set(Type.INT, 0, id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//Map Data
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x26, 0x26, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.BYTE);
|
||||||
|
map(Type.BOOLEAN);
|
||||||
|
map(Type.BOOLEAN, Type.NOTHING); // Locked
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//respawn
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x3A, 0x38, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Dimension ID
|
||||||
|
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);
|
||||||
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 0); // todo - do we need to store it from difficulty packet?
|
||||||
|
wrapper.user().get(ChunkLightStorage.class).clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn position
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
rewrite(247).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Brick Wall")));
|
||||||
|
rewrite(248).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Prismarine Wall")));
|
||||||
|
rewrite(249).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Red Sandstone Wall")));
|
||||||
|
rewrite(250).repItem(new Item((short) 246, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Wall")));
|
||||||
|
rewrite(251).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Granite Wall")));
|
||||||
|
rewrite(252).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Stone Brick Wall")));
|
||||||
|
rewrite(253).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Nether Brick Wall")));
|
||||||
|
rewrite(254).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Wall")));
|
||||||
|
rewrite(255).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Wall")));
|
||||||
|
rewrite(256).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Sandstone Wall")));
|
||||||
|
rewrite(257).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Wall")));
|
||||||
|
rewrite(258).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Wall")));
|
||||||
|
|
||||||
|
rewrite(121).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Stone Slab")));
|
||||||
|
rewrite(124).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 Cut Sandstone Slab")));
|
||||||
|
rewrite(132).repItem(new Item((short) 131, (byte) 1, (short) -1, getNamedTag("1.14 Cut Red Sandstone Slab")));
|
||||||
|
rewrite(492).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Slab")));
|
||||||
|
rewrite(493).repItem(new Item((short) 131, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Slab")));
|
||||||
|
rewrite(494).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Slab")));
|
||||||
|
rewrite(495).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Slab")));
|
||||||
|
rewrite(496).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Slab")));
|
||||||
|
rewrite(497).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Slab")));
|
||||||
|
rewrite(498).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Cut Sandstone Slab")));
|
||||||
|
rewrite(499).repItem(new Item((short) 130, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Slab")));
|
||||||
|
rewrite(500).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Granite Slab")));
|
||||||
|
rewrite(501).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Slab")));
|
||||||
|
rewrite(502).repItem(new Item((short) 129, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Slab")));
|
||||||
|
rewrite(503).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Slab")));
|
||||||
|
rewrite(504).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Slab")));
|
||||||
|
|
||||||
|
rewrite(478).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Stairs")));
|
||||||
|
rewrite(479).repItem(new Item((short) 371, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Stairs")));
|
||||||
|
rewrite(480).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Stairs")));
|
||||||
|
rewrite(481).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Stairs")));
|
||||||
|
rewrite(482).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Stairs")));
|
||||||
|
rewrite(483).repItem(new Item((short) 235, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Stairs")));
|
||||||
|
rewrite(484).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Stone Stairs")));
|
||||||
|
rewrite(485).repItem(new Item((short) 235, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Sandstone Stairs")));
|
||||||
|
rewrite(486).repItem(new Item((short) 278, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Stairs")));
|
||||||
|
rewrite(487).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Granite Stairs")));
|
||||||
|
rewrite(488).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Stairs")));
|
||||||
|
rewrite(489).repItem(new Item((short) 228, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Stairs")));
|
||||||
|
rewrite(490).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Stairs")));
|
||||||
|
rewrite(491).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Stairs")));
|
||||||
|
|
||||||
|
rewrite(108).repItem(new Item((short) 111, (byte) 1, (short) -1, getNamedTag("1.14 Cornflower")));
|
||||||
|
rewrite(109).repItem(new Item((short) 105, (byte) 1, (short) -1, getNamedTag("1.14 Lily of the Valley")));
|
||||||
|
rewrite(110).repItem(new Item((short) 100, (byte) 1, (short) -1, getNamedTag("1.14 Wither Rose")));
|
||||||
|
|
||||||
|
rewrite(614).repItem(new Item((short) 611, (byte) 1, (short) -1, getNamedTag("1.14 Bamboo")));
|
||||||
|
rewrite(857).repItem(new Item((short) 547, (byte) 1, (short) -1, getNamedTag("1.14 Suspicious Stew")));
|
||||||
|
rewrite(795).repItem(new Item((short) 793, (byte) 1, (short) -1, getNamedTag("1.14 Leather Horse Armor")));
|
||||||
|
|
||||||
|
rewrite(647).repItem(new Item((short) 635, (byte) 1, (short) -1, getNamedTag("1.14 Blue Dye")));
|
||||||
|
rewrite(648).repItem(new Item((short) 634, (byte) 1, (short) -1, getNamedTag("1.14 Brown Dye")));
|
||||||
|
rewrite(649).repItem(new Item((short) 631, (byte) 1, (short) -1, getNamedTag("1.14 Black Dye")));
|
||||||
|
rewrite(650).repItem(new Item((short) 646, (byte) 1, (short) -1, getNamedTag("1.14 White Dye")));
|
||||||
|
|
||||||
|
rewrite(505).repItem(new Item((short) 299, (byte) 1, (short) -1, getNamedTag("1.14 Scaffolding")));
|
||||||
|
rewrite(516).repItem(new Item((short) 515, (byte) 1, (short) -1, getNamedTag("1.14 Jigsaw Block")));
|
||||||
|
rewrite(517).repItem(new Item((short) 694, (byte) 1, (short) -1, getNamedTag("1.14 Composter")));
|
||||||
|
|
||||||
|
rewrite(864).repItem(new Item((short) 155, (byte) 1, (short) -1, getNamedTag("1.14 Barrel")));
|
||||||
|
rewrite(858).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Loom")));
|
||||||
|
rewrite(865).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.14 Smoker")));
|
||||||
|
rewrite(866).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.14 Blast Furnace")));
|
||||||
|
rewrite(867).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Cartography Table")));
|
||||||
|
rewrite(868).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Fletching Table")));
|
||||||
|
rewrite(869).repItem(new Item((short) 265, (byte) 1, (short) -1, getNamedTag("1.14 Grindstone")));
|
||||||
|
rewrite(870).repItem(new Item((short) 143, (byte) 1, (short) -1, getNamedTag("1.14 Lectern")));
|
||||||
|
rewrite(871).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Smithing Table")));
|
||||||
|
rewrite(872).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Stonecutter")));
|
||||||
|
|
||||||
|
rewrite(859).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Flower Banner Pattern")));
|
||||||
|
rewrite(860).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Creeper Banner Pattern")));
|
||||||
|
rewrite(861).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Skull Banner Pattern")));
|
||||||
|
rewrite(862).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Mojang Banner Pattern")));
|
||||||
|
rewrite(863).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Globe Banner Pattern")));
|
||||||
|
|
||||||
|
rewrite(873).repItem(new Item((short) 113, (byte) 1, (short) -1, getNamedTag("1.14 Bell")));
|
||||||
|
rewrite(874).repItem(new Item((short) 234, (byte) 1, (short) -1, getNamedTag("1.14 Lantern")));
|
||||||
|
rewrite(875).repItem(new Item((short) 820, (byte) 1, (short) -1, getNamedTag("1.14 Sweet Berries")));
|
||||||
|
rewrite(876).repItem(new Item((short) 146, (byte) 1, (short) -1, getNamedTag("1.14 Campfire")));
|
||||||
|
|
||||||
|
rewrite(590).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Spruce Sign")));
|
||||||
|
rewrite(591).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Birch Sign")));
|
||||||
|
rewrite(592).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Jungle Sign")));
|
||||||
|
rewrite(593).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Acacia Sign")));
|
||||||
|
rewrite(594).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Dark Oak Sign")));
|
||||||
|
|
||||||
|
rewrite(856).repItem(new Item((short) 525, (byte) 1, (short) -1, getNamedTag("1.14 Crossbow")));
|
||||||
|
|
||||||
|
rewrite(699).repItem(new Item((short) 721, (byte) 1, (short) -1, getNamedTag("1.14 Cat Spawn Egg")));
|
||||||
|
rewrite(712).repItem(new Item((short) 725, (byte) 1, (short) -1, getNamedTag("1.14 Fox Spawn Egg")));
|
||||||
|
rewrite(722).repItem(new Item((short) 735, (byte) 1, (short) -1, getNamedTag("1.14 Panda Spawn Egg")));
|
||||||
|
rewrite(726).repItem(new Item((short) 754, (byte) 1, (short) -1, getNamedTag("1.14 Pillager Spawn Egg")));
|
||||||
|
rewrite(730).repItem(new Item((short) 734, (byte) 1, (short) -1, getNamedTag("1.14 Ravager Spawn Egg")));
|
||||||
|
rewrite(741).repItem(new Item((short) 698, (byte) 1, (short) -1, getNamedTag("1.14 Trader Llama Spawn Egg")));
|
||||||
|
rewrite(747).repItem(new Item((short) 739, (byte) 1, (short) -1, getNamedTag("1.14 Wandering Trader Spawn Egg")));
|
||||||
|
|
||||||
|
enchantmentMappings.put("minecraft:multishot", "§7Multishot");
|
||||||
|
enchantmentMappings.put("minecraft:quick_charge", "§7Quick Charge");
|
||||||
|
enchantmentMappings.put("minecraft:piercing", "§7Piercing");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item handleItemToClient(Item i) {
|
||||||
|
Item item = super.handleItemToClient(i);
|
||||||
|
if (item == null) return null;
|
||||||
|
item.setIdentifier(getOldItemId(item.getIdentifier()));
|
||||||
|
|
||||||
|
CompoundTag tag;
|
||||||
|
if ((tag = item.getTag()) != null) {
|
||||||
|
// Display Name now uses JSON
|
||||||
|
if (tag.get("display") instanceof CompoundTag) {
|
||||||
|
CompoundTag display = tag.get("display");
|
||||||
|
if (((CompoundTag) tag.get("display")).get("Lore") instanceof ListTag) {
|
||||||
|
ListTag lore = display.get("Lore");
|
||||||
|
ListTag via = display.get(NBT_TAG_NAME + "|Lore");
|
||||||
|
if (via != null) {
|
||||||
|
display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via)));
|
||||||
|
} else {
|
||||||
|
for (Tag loreEntry : lore) {
|
||||||
|
if (loreEntry instanceof StringTag) {
|
||||||
|
((StringTag) loreEntry).setValue(
|
||||||
|
ChatRewriter.jsonTextToLegacy(
|
||||||
|
((StringTag) loreEntry).getValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
display.remove(NBT_TAG_NAME + "|Lore");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.get("Enchantments") instanceof ListTag) {
|
||||||
|
rewriteEnchantmentsToClient(tag, false);
|
||||||
|
}
|
||||||
|
if (tag.get("StoredEnchantments") instanceof ListTag) {
|
||||||
|
rewriteEnchantmentsToClient(tag, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rewriteEnchantmentsToClient(CompoundTag tag, boolean storedEnchant) {
|
||||||
|
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||||
|
ListTag enchantments = tag.get(key);
|
||||||
|
ListTag noMapped = new ListTag(NBT_TAG_NAME + "|" + key, CompoundTag.class);
|
||||||
|
List<Tag> lore = new ArrayList<>();
|
||||||
|
for (Tag enchantmentEntry : enchantments.clone()) {
|
||||||
|
String newId = (String) ((CompoundTag) enchantmentEntry).get("id").getValue();
|
||||||
|
String enchantmentName = enchantmentMappings.get(newId);
|
||||||
|
if (enchantmentName != null) {
|
||||||
|
enchantments.remove(enchantmentEntry);
|
||||||
|
lore.add(new StringTag("", enchantmentMappings.get(newId) + " " + BlockItemPackets1_13.getRomanNumber((Short) ((CompoundTag) enchantmentEntry).get("lvl").getValue())));
|
||||||
|
noMapped.add(enchantmentEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!lore.isEmpty()) {
|
||||||
|
if (!storedEnchant && enchantments.size() == 0) {
|
||||||
|
CompoundTag dummyEnchantment = new CompoundTag("");
|
||||||
|
dummyEnchantment.put(new StringTag("id", ""));
|
||||||
|
dummyEnchantment.put(new ShortTag("lvl", (short) 0));
|
||||||
|
enchantments.add(dummyEnchantment);
|
||||||
|
|
||||||
|
tag.put(new ByteTag(NBT_TAG_NAME + "|dummyEnchant"));
|
||||||
|
}
|
||||||
|
|
||||||
|
tag.put(noMapped);
|
||||||
|
|
||||||
|
CompoundTag display = tag.get("display");
|
||||||
|
if (display == null) {
|
||||||
|
tag.put(display = new CompoundTag("display"));
|
||||||
|
}
|
||||||
|
ListTag loreTag = display.get("Lore");
|
||||||
|
if (loreTag == null) {
|
||||||
|
display.put(loreTag = new ListTag("Lore", StringTag.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
lore.addAll(loreTag.getValue());
|
||||||
|
loreTag.setValue(lore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Item handleItemToServer(Item item) {
|
||||||
|
if (item == null) return null;
|
||||||
|
item.setIdentifier(getNewItemId(item.getIdentifier()));
|
||||||
|
item = super.handleItemToServer(item);
|
||||||
|
|
||||||
|
CompoundTag tag;
|
||||||
|
if ((tag = item.getTag()) != null) {
|
||||||
|
// Display Lore now uses JSON
|
||||||
|
if (tag.get("display") instanceof CompoundTag) {
|
||||||
|
CompoundTag display = tag.get("display");
|
||||||
|
if (display.get("Lore") instanceof ListTag) {
|
||||||
|
ListTag lore = display.get("Lore");
|
||||||
|
display.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|Lore", ConverterRegistry.convertToValue(lore)));
|
||||||
|
for (Tag loreEntry : lore) {
|
||||||
|
if (loreEntry instanceof StringTag) {
|
||||||
|
((StringTag) loreEntry).setValue(
|
||||||
|
ChatRewriter.legacyTextToJson(
|
||||||
|
((StringTag) loreEntry).getValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag.contains(NBT_TAG_NAME + "|Enchantments")) {
|
||||||
|
rewriteEnchantmentsToServer(tag, false);
|
||||||
|
}
|
||||||
|
if (tag.contains(NBT_TAG_NAME + "|StoredEnchantments")) {
|
||||||
|
rewriteEnchantmentsToServer(tag, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rewriteEnchantmentsToServer(CompoundTag tag, boolean storedEnchant) {
|
||||||
|
String key = storedEnchant ? "StoredEnchantments" : "Enchantments";
|
||||||
|
ListTag newEnchantments = tag.get(NBT_TAG_NAME + "|" + key);
|
||||||
|
ListTag enchantments = tag.contains(key) ? tag.get(key) : new ListTag(key, CompoundTag.class);
|
||||||
|
if (!storedEnchant && tag.contains(NBT_TAG_NAME + "|dummyEnchant")) {
|
||||||
|
tag.remove(NBT_TAG_NAME + "|dummyEnchant");
|
||||||
|
for (Tag enchantment : enchantments.clone()) {
|
||||||
|
String id = (String) ((CompoundTag) enchantment).get("id").getValue();
|
||||||
|
if (id.isEmpty())
|
||||||
|
enchantments.remove(enchantment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag display = tag.get("display");
|
||||||
|
// A few null checks just to be safe, though they shouldn't actually be
|
||||||
|
ListTag lore = display != null ? display.get("Lore") : null;
|
||||||
|
for (Tag enchantment : newEnchantments.clone()) {
|
||||||
|
enchantments.add(enchantment);
|
||||||
|
if (lore != null && lore.size() != 0)
|
||||||
|
lore.remove(lore.get(0));
|
||||||
|
}
|
||||||
|
if (lore != null && lore.size() == 0) {
|
||||||
|
display.remove("Lore");
|
||||||
|
if (display.isEmpty())
|
||||||
|
tag.remove("display");
|
||||||
|
}
|
||||||
|
tag.put(enchantments);
|
||||||
|
tag.remove(newEnchantments.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CompoundTag getNamedTag(String text) {
|
||||||
|
CompoundTag tag = new CompoundTag("");
|
||||||
|
tag.put(new CompoundTag("display"));
|
||||||
|
((CompoundTag) tag.get("display")).put(new StringTag("Name", ChatRewriter.legacyTextToJson(text)));
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int getNewItemId(int id) {
|
||||||
|
Integer newId = MappingData.oldToNewItems.get(id);
|
||||||
|
if (newId == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 item for 1.13.2 item " + id);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static int getOldItemId(int id) {
|
||||||
|
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||||
|
if (oldId == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 item for 1.14 item " + id);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return oldId;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,563 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.api.entities.meta.MetaHandler;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.EntityData;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_14;
|
||||||
|
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityTypeMapping;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.VillagerData;
|
||||||
|
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_13_2;
|
||||||
|
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_13_2;
|
||||||
|
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
|
||||||
|
// Spawn Object
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
|
map(Type.UUID); // 1 - UUID
|
||||||
|
map(Type.VAR_INT, Type.BYTE); // 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
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
byte type = wrapper.get(Type.BYTE, 0);
|
||||||
|
EntityType1_14.EntityType entityType = EntityType1_14.getTypeFromId(type);
|
||||||
|
if (entityType == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.14 entity type " + type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
entityType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int id = wrapper.get(Type.BYTE, 0);
|
||||||
|
EntityType1_13.EntityType entityType = EntityType1_13.getTypeFromId(EntityTypeMapping.getOldId(id).orElse(id), false);
|
||||||
|
Optional<EntityType1_13.ObjectType> type;
|
||||||
|
if (entityType.isOrHasParent(EntityType1_13.EntityType.MINECART_ABSTRACT)) {
|
||||||
|
type = Optional.of(EntityType1_13.ObjectType.MINECART);
|
||||||
|
int data = 0;
|
||||||
|
switch (entityType) {
|
||||||
|
case CHEST_MINECART:
|
||||||
|
data = 1;
|
||||||
|
break;
|
||||||
|
case FURNACE_MINECART:
|
||||||
|
data = 2;
|
||||||
|
break;
|
||||||
|
case TNT_MINECART:
|
||||||
|
data = 3;
|
||||||
|
break;
|
||||||
|
case SPAWNER_MINECART:
|
||||||
|
data = 4;
|
||||||
|
break;
|
||||||
|
case HOPPER_MINECART:
|
||||||
|
data = 5;
|
||||||
|
break;
|
||||||
|
case COMMANDBLOCK_MINECART:
|
||||||
|
data = 6;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (data != 0)
|
||||||
|
wrapper.set(Type.INT, 0, data);
|
||||||
|
} else {
|
||||||
|
type = EntityType1_13.ObjectType.fromEntityType(entityType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type.isPresent()) {
|
||||||
|
wrapper.set(Type.BYTE, 0, (byte) type.get().getId());
|
||||||
|
}
|
||||||
|
if (type.isPresent() && type.get() == EntityType1_13.ObjectType.FALLING_BLOCK) {
|
||||||
|
int blockState = wrapper.get(Type.INT, 0);
|
||||||
|
int combined = BlockItemPackets1_13.toOldId(blockState);
|
||||||
|
combined = ((combined >> 4) & 0xFFF) | ((combined & 0xF) << 12);
|
||||||
|
wrapper.set(Type.INT, 0, combined);
|
||||||
|
} else if (type.isPresent() && type.get() == EntityType1_13.ObjectType.ITEM_FRAME) {
|
||||||
|
int data = wrapper.get(Type.INT, 0);
|
||||||
|
switch (data) {
|
||||||
|
case 3:
|
||||||
|
data = 0;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
data = 1;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
data = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wrapper.set(Type.INT, 0, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn mob packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
|
map(Type.DOUBLE); // 3 - X
|
||||||
|
map(Type.DOUBLE); // 4 - Y
|
||||||
|
map(Type.DOUBLE); // 5 - Z
|
||||||
|
map(Type.BYTE); // 6 - Yaw
|
||||||
|
map(Type.BYTE); // 7 - Pitch
|
||||||
|
map(Type.BYTE); // 8 - Head Pitch
|
||||||
|
map(Type.SHORT); // 9 - Velocity X
|
||||||
|
map(Type.SHORT); // 10 - Velocity Y
|
||||||
|
map(Type.SHORT); // 11 - Velocity Z
|
||||||
|
map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 12 - Metadata
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
EntityType1_14.EntityType entityType = EntityType1_14.getTypeFromId(type);
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
entityType
|
||||||
|
);
|
||||||
|
Optional<Integer> oldId = EntityTypeMapping.getOldId(type);
|
||||||
|
if (!oldId.isPresent()) {
|
||||||
|
Optional<EntityData> oldType = getEntityData(entityType);
|
||||||
|
if (!oldType.isPresent()) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType);
|
||||||
|
wrapper.cancel();
|
||||||
|
} else {
|
||||||
|
wrapper.set(Type.VAR_INT, 1, oldType.get().getReplacementId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
wrapper.set(Type.VAR_INT, 1, oldId.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle entity type & metadata
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
AbstractEntityType type = getEntityType(wrapper.user(), entityId);
|
||||||
|
|
||||||
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_13_2.METADATA_LIST, 0));
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
storage
|
||||||
|
);
|
||||||
|
|
||||||
|
Optional<EntityData> optEntDat = getEntityData(type);
|
||||||
|
if (optEntDat.isPresent()) {
|
||||||
|
EntityData data = optEntDat.get();
|
||||||
|
|
||||||
|
Optional<Integer> replacementId = EntityTypeMapping.getOldId(data.getReplacementId());
|
||||||
|
wrapper.set(Type.VAR_INT, 1, replacementId.orElse(EntityType1_13.EntityType.ZOMBIE.getId()));
|
||||||
|
if (data.hasBaseMeta())
|
||||||
|
data.getDefaultMeta().handle(storage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
wrapper.set(
|
||||||
|
Types1_13_2.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
storage.getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Experience Orb
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
|
|
||||||
|
// Track entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType1_14.EntityType.XP_ORB
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn painting
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.UUID);
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
|
map(Type.BYTE);
|
||||||
|
|
||||||
|
// Track entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType1_14.EntityType.PAINTING
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn player packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Player UUID
|
||||||
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
map(Type.DOUBLE); // 3 - Y
|
||||||
|
map(Type.DOUBLE); // 4 - Z
|
||||||
|
map(Type.BYTE); // 5 - Yaw
|
||||||
|
map(Type.BYTE); // 6 - Pitch
|
||||||
|
map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 7 - Metadata
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
|
||||||
|
EntityType1_14.EntityType entType = EntityType1_14.EntityType.PLAYER;
|
||||||
|
// Register Type ID
|
||||||
|
addTrackedEntity(wrapper.user(), entityId, entType);
|
||||||
|
wrapper.set(Types1_13_2.METADATA_LIST, 0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
entityId,
|
||||||
|
new MetaStorage(wrapper.get(Types1_13_2.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Destroy entities
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x37, 0x35, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||||
|
getEntityTracker(wrapper.user()).removeEntity(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Metadata packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x43, 0x3F, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Types1_14.METADATA_LIST, Types1_13_2.METADATA_LIST); // 1 - Metadata list
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
|
||||||
|
wrapper.set(Types1_13_2.METADATA_LIST, 0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
entityId,
|
||||||
|
new MetaStorage(wrapper.get(Types1_13_2.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//join game
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, 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 {
|
||||||
|
// Store the player
|
||||||
|
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 1);
|
||||||
|
clientChunks.setEnvironment(dimensionId);
|
||||||
|
|
||||||
|
int entityId = wrapper.get(Type.INT, 0);
|
||||||
|
|
||||||
|
// Register Type ID
|
||||||
|
addTrackedEntity(wrapper.user(), entityId, EntityType1_14.EntityType.PLAYER);
|
||||||
|
|
||||||
|
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||||
|
wrapper.passthrough(Type.STRING); // Level Type
|
||||||
|
wrapper.read(Type.VAR_INT); //Read View Distance
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
setDisplayNameJson(true);
|
||||||
|
setDisplayNameMetaType(MetaType1_13_2.OptChat);
|
||||||
|
|
||||||
|
regEntType(EntityType1_14.EntityType.CAT, EntityType1_14.EntityType.OCELOT).mobName("Cat");
|
||||||
|
regEntType(EntityType1_14.EntityType.TRADER_LLAMA, EntityType1_14.EntityType.LLAMA).mobName("Trader Llama");
|
||||||
|
regEntType(EntityType1_14.EntityType.FOX, EntityType1_14.EntityType.WOLF).mobName("Fox");
|
||||||
|
regEntType(EntityType1_14.EntityType.PANDA, EntityType1_14.EntityType.POLAR_BEAR).mobName("Panda");
|
||||||
|
regEntType(EntityType1_14.EntityType.PILLAGER, EntityType1_14.EntityType.VILLAGER).mobName("Pillager");
|
||||||
|
regEntType(EntityType1_14.EntityType.WANDERING_TRADER, EntityType1_14.EntityType.VILLAGER).mobName("Wandering Trader");
|
||||||
|
regEntType(EntityType1_14.EntityType.RAVAGER, EntityType1_14.EntityType.COW).mobName("Ravager");
|
||||||
|
|
||||||
|
registerMetaHandler().handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
int typeId = meta.getMetaType().getTypeID();
|
||||||
|
if (typeId <= 15) {
|
||||||
|
meta.setMetaType(MetaType1_13_2.byId(typeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
MetaType type = meta.getMetaType();
|
||||||
|
|
||||||
|
if (type == MetaType1_13_2.Slot) {
|
||||||
|
Item item = (Item) meta.getValue();
|
||||||
|
meta.setValue(getProtocol().getBlockItemPackets().handleItemToClient(item));
|
||||||
|
} else if (type == MetaType1_13_2.BlockID) {
|
||||||
|
int blockstate = (Integer) meta.getValue();
|
||||||
|
meta.setValue(getProtocol().getNewBlockStateId(blockstate));
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.PILLAGER, 15).removed();
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 15).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 16).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 17).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 18).removed();
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 15).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 16).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 17).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 18).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 19).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 20).removed();
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 18).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 19).removed();
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 20).removed();
|
||||||
|
|
||||||
|
registerMetaHandler().handle(e -> {
|
||||||
|
AbstractEntityType type = e.getEntity().getType();
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
if (type.isOrHasParent(EntityType1_14.EntityType.ABSTRACT_ILLAGER_BASE) || type == EntityType1_14.EntityType.RAVAGER || type == EntityType1_14.EntityType.WITCH) {
|
||||||
|
int index = e.getIndex();
|
||||||
|
if (index == 14) {
|
||||||
|
//TODO handle
|
||||||
|
throw new RemovedValueException();
|
||||||
|
} else if (index > 14) {
|
||||||
|
meta.setId(index - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.AREA_EFFECT_CLOUD, 10).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
Particle particle = (Particle) meta.getValue();
|
||||||
|
particle.setId(getOldParticleId(particle.getId()));
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.FIREWORKS_ROCKET, 8).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
meta.setMetaType(MetaType1_13_2.VarInt);
|
||||||
|
Integer value = (Integer) meta.getValue();
|
||||||
|
if (value == null) meta.setValue(0);
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.ABSTRACT_ARROW, true).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
int index = e.getIndex();
|
||||||
|
if (index == 9) {
|
||||||
|
throw new RemovedValueException();
|
||||||
|
} else if (index > 9) {
|
||||||
|
meta.setId(index - 1);
|
||||||
|
}
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
MetaHandler villagerDataHandler = e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
VillagerData villagerData = (VillagerData) meta.getValue();
|
||||||
|
meta.setValue(villagerDataToProfession(villagerData));
|
||||||
|
meta.setMetaType(MetaType1_13_2.VarInt);
|
||||||
|
return meta;
|
||||||
|
};
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.ZOMBIE_VILLAGER, 18).handle(villagerDataHandler);
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.VILLAGER, 15).handle(villagerDataHandler);
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.ZOMBIE, true).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
int index = e.getIndex();
|
||||||
|
if (index >= 16) {
|
||||||
|
meta.setId(index + 1);
|
||||||
|
}
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove bed location - todo send sleep packet
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.LIVINGENTITY, true).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
int index = e.getIndex();
|
||||||
|
if (index == 12) {
|
||||||
|
throw new RemovedValueException();
|
||||||
|
} else if (index > 12) {
|
||||||
|
meta.setId(index - 1);
|
||||||
|
}
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
int index = e.getIndex();
|
||||||
|
if (index == 6) {
|
||||||
|
throw new RemovedValueException();
|
||||||
|
} else if (index > 6) {
|
||||||
|
meta.setId(index - 1);
|
||||||
|
}
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
int typeId = meta.getMetaType().getTypeID();
|
||||||
|
if (typeId > 15) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("New 1.14 metadata was not handled: " + meta + " entity: " + e.getEntity().getType());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.OCELOT, 13).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
meta.setId(15);
|
||||||
|
meta.setMetaType(MetaType1_13_2.VarInt);
|
||||||
|
meta.setValue(0);
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
registerMetaHandler().filter(EntityType1_14.EntityType.CAT).handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
if (meta.getId() == 15) {
|
||||||
|
meta.setValue(1);
|
||||||
|
} else if (meta.getId() == 13) {
|
||||||
|
meta.setValue((byte) ((byte) meta.getValue() & 0x4));
|
||||||
|
}
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public int villagerDataToProfession(VillagerData data) {
|
||||||
|
switch (data.getProfession()) {
|
||||||
|
case 1: // Armorer
|
||||||
|
case 10: // Mason
|
||||||
|
case 13: // Toolsmith
|
||||||
|
case 14: // Weaponsmith
|
||||||
|
return 3; // Blacksmith
|
||||||
|
case 2: // Butcher
|
||||||
|
case 8: // Leatherworker
|
||||||
|
return 4; // Butcher
|
||||||
|
case 3: // Cartographer
|
||||||
|
case 9: // Librarian
|
||||||
|
return 1; // Librarian
|
||||||
|
case 4: // Cleric
|
||||||
|
return 2; // Priest
|
||||||
|
case 5: // Farmer
|
||||||
|
case 6: // Fisherman
|
||||||
|
case 7: // Fletcher
|
||||||
|
case 12: // Shepherd
|
||||||
|
return 0; // Farmer
|
||||||
|
case 0: // None
|
||||||
|
case 11: // Nitwit
|
||||||
|
default:
|
||||||
|
return 5; // Nitwit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getOldParticleId(int id) {
|
||||||
|
if (id >= 45) {
|
||||||
|
id -= 1; // new 39 -> 44
|
||||||
|
}
|
||||||
|
if (id >= 30) {
|
||||||
|
id -= 1; // skip new short happy villager
|
||||||
|
}
|
||||||
|
if (id >= 28) {
|
||||||
|
id -= 1; // new 24 -> 27
|
||||||
|
}
|
||||||
|
if (id >= 14) {
|
||||||
|
id -= 1; // new water drip 11 -> 13
|
||||||
|
}
|
||||||
|
if (id >= 12) {
|
||||||
|
id -= 2; // new lava drips 10, 11
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,148 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.Position;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
|
||||||
|
|
||||||
|
// Server Difficulty
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x0D, 0x0D, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.UNSIGNED_BYTE);
|
||||||
|
map(Type.BOOLEAN, Type.NOTHING); // Locked
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Open Sign Editor
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x2F, 0x2C, new PacketRemapper() { // c
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION1_14, Type.POSITION);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Query Block NBT
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Edit Book
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x0C, 0x0B, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
getProtocol().getBlockItemPackets().handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Player Digging
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x1A, 0x18, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
|
map(Type.BYTE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Recipe Book Data
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x1D, 0x1B, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int type = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
if (type == 0) {
|
||||||
|
wrapper.passthrough(Type.STRING);
|
||||||
|
} else if (type == 1) {
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Book Open
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); // Crafting Recipe Filter Active
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Book Open
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Filter Active
|
||||||
|
|
||||||
|
// Blast furnace/smoker data
|
||||||
|
wrapper.write(Type.BOOLEAN, false);
|
||||||
|
wrapper.write(Type.BOOLEAN, false);
|
||||||
|
wrapper.write(Type.BOOLEAN, false);
|
||||||
|
wrapper.write(Type.BOOLEAN, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update Command Block
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x24, 0x22, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update Structure Block
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x28, 0x25, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update Sign
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x29, 0x26, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.POSITION, Type.POSITION1_14);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Player Block Placement
|
||||||
|
protocol.registerIncoming(State.PLAY, 0x2C, 0x29, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
Position position = wrapper.read(Type.POSITION);
|
||||||
|
int face = wrapper.read(Type.VAR_INT);
|
||||||
|
int hand = wrapper.read(Type.VAR_INT);
|
||||||
|
float x = wrapper.read(Type.FLOAT);
|
||||||
|
float y = wrapper.read(Type.FLOAT);
|
||||||
|
float z = wrapper.read(Type.FLOAT);
|
||||||
|
|
||||||
|
wrapper.write(Type.VAR_INT, hand);
|
||||||
|
wrapper.write(Type.POSITION1_14, position);
|
||||||
|
wrapper.write(Type.VAR_INT, face);
|
||||||
|
wrapper.write(Type.FLOAT, x);
|
||||||
|
wrapper.write(Type.FLOAT, y);
|
||||||
|
wrapper.write(Type.FLOAT, z);
|
||||||
|
wrapper.write(Type.BOOLEAN, false); // Inside block
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.SoundMapping;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_13_2To1_14 protocol) {
|
||||||
|
// Sound Effect
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x51, 0x4D, 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, SoundMapping.getOldSound(wrapper.get(Type.VAR_INT, 0)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.data.StoredObject;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ChunkLightStorage extends StoredObject {
|
||||||
|
public static final byte[] FULL_LIGHT = new byte[2048];
|
||||||
|
public static final byte[] EMPTY_LIGHT = new byte[2048];
|
||||||
|
private static Constructor<?> fastUtilLongObjectHashMap;
|
||||||
|
|
||||||
|
private final Map<Long, ChunkLight> storedLight = createLongObjectMap();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Arrays.fill(FULL_LIGHT, (byte) 0xFF);
|
||||||
|
Arrays.fill(EMPTY_LIGHT, (byte) 0x0);
|
||||||
|
try {
|
||||||
|
fastUtilLongObjectHashMap = Class.forName("it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap").getConstructor();
|
||||||
|
} catch (ClassNotFoundException | NoSuchMethodException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChunkLightStorage(UserConnection user) {
|
||||||
|
super(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStoredLight(byte[][] skyLight, byte[][] blockLight, int x, int z) {
|
||||||
|
storedLight.put(getChunkSectionIndex(x, z), new ChunkLight(skyLight, blockLight));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChunkLight getStoredLight(int x, int z) {
|
||||||
|
return storedLight.get(getChunkSectionIndex(x, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
storedLight.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadChunk(int x, int z) {
|
||||||
|
storedLight.remove(getChunkSectionIndex(x, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
private long getChunkSectionIndex(int x, int z) {
|
||||||
|
return ((x & 0x3FFFFFFL) << 38) | (z & 0x3FFFFFFL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Long, ChunkLight> createLongObjectMap() {
|
||||||
|
if (fastUtilLongObjectHashMap != null) {
|
||||||
|
try {
|
||||||
|
return (Map<Long, ChunkLight>) fastUtilLongObjectHashMap.newInstance();
|
||||||
|
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ChunkLight {
|
||||||
|
private final byte[][] skyLight;
|
||||||
|
private final byte[][] blockLight;
|
||||||
|
|
||||||
|
public ChunkLight(byte[][] skyLight, byte[][] blockLight) {
|
||||||
|
this.skyLight = skyLight;
|
||||||
|
this.blockLight = blockLight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[][] getSkyLight() {
|
||||||
|
return skyLight;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[][] getBlockLight() {
|
||||||
|
return blockLight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,48 +0,0 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
|
||||||
|
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets;
|
|
||||||
import us.myles.ViaVersion.api.Via;
|
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType;
|
|
||||||
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_13;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MetadataRewriter {
|
|
||||||
|
|
||||||
public static void handleMetadata(int entityId, Entity1_13Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
|
||||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
|
||||||
try {
|
|
||||||
// 1.13 changed item to flat item (no data)
|
|
||||||
if (metadata.getMetaType() == MetaType1_13.Slot) {
|
|
||||||
InventoryPackets.toClient((Item) metadata.getValue());
|
|
||||||
} else if (metadata.getMetaType() == MetaType1_13.BlockID) {
|
|
||||||
// Convert to new block id
|
|
||||||
int data = (int) metadata.getValue();
|
|
||||||
metadata.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
|
||||||
}
|
|
||||||
if (type == null) continue;
|
|
||||||
if (type.isOrHasParent(Entity1_13Types.EntityType.MINECART_ABSTRACT) && metadata.getId() == 9) {
|
|
||||||
// New block format
|
|
||||||
int data = (int) metadata.getValue();
|
|
||||||
metadata.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
|
||||||
}
|
|
||||||
if(type.is(EntityType.ITEM)){
|
|
||||||
|
|
||||||
}
|
|
||||||
} 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +1,10 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1;
|
||||||
|
|
||||||
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets;
|
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets;
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.EntityPackets1_13_1;
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets;
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.InventoryPackets1_13_1;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets.WorldPackets1_13_1;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
import us.myles.ViaVersion.api.data.UserConnection;
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
@ -12,16 +13,15 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|||||||
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
import us.myles.ViaVersion.api.remapper.ValueTransformer;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
EntityPackets.register(this);
|
new EntityPackets1_13_1().register(this);
|
||||||
InventoryPackets.register(this);
|
InventoryPackets1_13_1.register(this);
|
||||||
WorldPackets.register(this);
|
WorldPackets1_13_1.register(this);
|
||||||
|
|
||||||
//Tab complete
|
//Tab complete
|
||||||
registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
registerIncoming(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||||
@ -47,6 +47,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
|||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
InventoryPackets1_13_1.toServer(wrapper.get(Type.FLAT_ITEM, 0));
|
||||||
wrapper.write(Type.VAR_INT, 0);
|
wrapper.write(Type.VAR_INT, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -94,6 +95,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
|||||||
wrapper.passthrough(Type.STRING);
|
wrapper.passthrough(Type.STRING);
|
||||||
wrapper.passthrough(Type.FLOAT);
|
wrapper.passthrough(Type.FLOAT);
|
||||||
wrapper.passthrough(Type.VAR_INT);
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
short flags = wrapper.read(Type.UNSIGNED_BYTE);
|
short flags = wrapper.read(Type.UNSIGNED_BYTE);
|
||||||
if ((flags & 0x04) != 0) flags |= 0x02;
|
if ((flags & 0x04) != 0) flags |= 0x02;
|
||||||
wrapper.write(Type.UNSIGNED_BYTE, flags);
|
wrapper.write(Type.UNSIGNED_BYTE, flags);
|
||||||
@ -126,7 +128,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
|||||||
wrapper.passthrough(Type.STRING); // Title
|
wrapper.passthrough(Type.STRING); // Title
|
||||||
wrapper.passthrough(Type.STRING); // Description
|
wrapper.passthrough(Type.STRING); // Description
|
||||||
Item icon = wrapper.passthrough(Type.FLAT_ITEM);
|
Item icon = wrapper.passthrough(Type.FLAT_ITEM);
|
||||||
InventoryPackets.toClient(icon);
|
InventoryPackets1_13_1.toClient(icon);
|
||||||
wrapper.passthrough(Type.VAR_INT); // Frame type
|
wrapper.passthrough(Type.VAR_INT); // Frame type
|
||||||
int flags = wrapper.passthrough(Type.INT); // Flags
|
int flags = wrapper.passthrough(Type.INT); // Flags
|
||||||
if ((flags & 1) != 0)
|
if ((flags & 1) != 0)
|
||||||
@ -167,7 +169,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
|||||||
wrapper.passthrough(Type.STRING);
|
wrapper.passthrough(Type.STRING);
|
||||||
Integer[] items = wrapper.passthrough(Type.VAR_INT_ARRAY);
|
Integer[] items = wrapper.passthrough(Type.VAR_INT_ARRAY);
|
||||||
for (int j = 0; j < items.length; j++) {
|
for (int j = 0; j < items.length; j++) {
|
||||||
items[j] = InventoryPackets.getOldItemId(items[j]);
|
items[j] = InventoryPackets1_13_1.getOldItemId(items[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,8 +182,8 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
|||||||
public static int getNewBlockStateId(int blockId) {
|
public static int getNewBlockStateId(int blockId) {
|
||||||
if (blockId > 8590) {
|
if (blockId > 8590) {
|
||||||
blockId -= 17;
|
blockId -= 17;
|
||||||
} else if (blockId > 8573) {
|
} else if (blockId > 8588) {
|
||||||
blockId = 0; //TODO replace new blocks
|
blockId = 8573;
|
||||||
} else if (blockId > 8479) {
|
} else if (blockId > 8479) {
|
||||||
blockId -= 16;
|
blockId -= 16;
|
||||||
} else if (blockId > 8469 && blockId % 2 == 0) {
|
} else if (blockId > 8469 && blockId % 2 == 0) {
|
||||||
@ -212,9 +214,15 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(UserConnection userConnection) {
|
public void init(UserConnection user) {
|
||||||
userConnection.put(new EntityTracker(userConnection));
|
// Register EntityTracker if it doesn't exist yet.
|
||||||
if (!userConnection.has(ClientWorld.class))
|
if (!user.has(EntityTracker.class))
|
||||||
userConnection.put(new ClientWorld(userConnection));
|
user.put(new EntityTracker(user));
|
||||||
|
|
||||||
|
// Init protocol in EntityTracker
|
||||||
|
user.get(EntityTracker.class).initProtocol(this);
|
||||||
|
|
||||||
|
if (!user.has(ClientWorld.class))
|
||||||
|
user.put(new ClientWorld(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,152 +0,0 @@
|
|||||||
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.MetadataRewriter;
|
|
||||||
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_13Types;
|
|
||||||
import us.myles.ViaVersion.api.entities.Entity1_13Types.EntityType;
|
|
||||||
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_13;
|
|
||||||
import us.myles.ViaVersion.packets.State;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.EntityTracker;
|
|
||||||
|
|
||||||
public class EntityPackets {
|
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
|
||||||
|
|
||||||
//spawn entity
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x0, 0x0, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.VAR_INT); // 0 - Entity id
|
|
||||||
map(Type.UUID); // 1 - UUID
|
|
||||||
map(Type.BYTE); // 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
|
|
||||||
|
|
||||||
// Track Entity
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
|
||||||
byte type = wrapper.get(Type.BYTE, 0);
|
|
||||||
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, true);
|
|
||||||
|
|
||||||
if (entType != null) {
|
|
||||||
if (entType.is(Entity1_13Types.EntityType.FALLING_BLOCK)) {
|
|
||||||
int data = wrapper.get(Type.INT, 0);
|
|
||||||
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Register Type ID
|
|
||||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Spawn mob packet
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
|
||||||
map(Type.UUID); // 1 - Entity UUID
|
|
||||||
map(Type.VAR_INT); // 2 - Entity Type
|
|
||||||
map(Type.DOUBLE); // 3 - X
|
|
||||||
map(Type.DOUBLE); // 4 - Y
|
|
||||||
map(Type.DOUBLE); // 5 - Z
|
|
||||||
map(Type.BYTE); // 6 - Yaw
|
|
||||||
map(Type.BYTE); // 7 - Pitch
|
|
||||||
map(Type.BYTE); // 8 - Head Pitch
|
|
||||||
map(Type.SHORT); // 9 - Velocity X
|
|
||||||
map(Type.SHORT); // 10 - Velocity Y
|
|
||||||
map(Type.SHORT); // 11 - Velocity Z
|
|
||||||
map(Types1_13.METADATA_LIST); // 12 - Metadata
|
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
|
||||||
int type = wrapper.get(Type.VAR_INT, 1);
|
|
||||||
|
|
||||||
Entity1_13Types.EntityType entType = Entity1_13Types.getTypeFromId(type, false);
|
|
||||||
|
|
||||||
// Register Type ID
|
|
||||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
|
||||||
|
|
||||||
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Spawn player packet
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
|
||||||
map(Type.UUID); // 1 - Player UUID
|
|
||||||
map(Type.DOUBLE); // 2 - X
|
|
||||||
map(Type.DOUBLE); // 3 - Y
|
|
||||||
map(Type.DOUBLE); // 4 - Z
|
|
||||||
map(Type.BYTE); // 5 - Yaw
|
|
||||||
map(Type.BYTE); // 6 - Pitch
|
|
||||||
map(Types1_13.METADATA_LIST); // 7 - Metadata
|
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
|
||||||
|
|
||||||
Entity1_13Types.EntityType entType = Entity1_13Types.EntityType.PLAYER;
|
|
||||||
// Register Type ID
|
|
||||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
|
||||||
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Destroy entities
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
|
||||||
wrapper.user().get(EntityTracker.class).removeEntity(entity);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Metadata packet
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
|
||||||
map(Types1_13.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<EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId);
|
|
||||||
MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_13.METADATA_LIST, 0), wrapper.user());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,360 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.packets;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.ViaBackwards;
|
||||||
|
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_12;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
|
||||||
|
import nl.matsv.viabackwards.api.entities.types.EntityType1_13.EntityType;
|
||||||
|
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
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_13;
|
||||||
|
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_13;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
|
public class EntityPackets1_13_1 extends EntityRewriter<Protocol1_13To1_13_1> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets(Protocol1_13To1_13_1 protocol) {
|
||||||
|
|
||||||
|
// Spawn Object
|
||||||
|
protocol.out(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity id
|
||||||
|
map(Type.UUID); // 1 - UUID
|
||||||
|
map(Type.BYTE); // 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
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
byte type = wrapper.get(Type.BYTE, 0);
|
||||||
|
EntityType entType = EntityType1_13.getTypeFromId(type, true);
|
||||||
|
if (entType == null) {
|
||||||
|
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13 entity type " + type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rewrite falling block
|
||||||
|
if (entType.is(EntityType.FALLING_BLOCK)) {
|
||||||
|
int data = wrapper.get(Type.INT, 0);
|
||||||
|
wrapper.set(Type.INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
entityId,
|
||||||
|
entType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Experience Orb
|
||||||
|
protocol.out(State.PLAY, 0x01, 0x01, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.XP_ORB
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Global Entity
|
||||||
|
protocol.out(State.PLAY, 0x02, 0x02, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.BYTE);
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.LIGHTNING_BOLT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Mob
|
||||||
|
protocol.out(State.PLAY, 0x3, 0x3, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
|
map(Type.DOUBLE); // 3 - X
|
||||||
|
map(Type.DOUBLE); // 4 - Y
|
||||||
|
map(Type.DOUBLE); // 5 - Z
|
||||||
|
map(Type.BYTE); // 6 - Yaw
|
||||||
|
map(Type.BYTE); // 7 - Pitch
|
||||||
|
map(Type.BYTE); // 8 - Head Pitch
|
||||||
|
map(Type.SHORT); // 9 - Velocity X
|
||||||
|
map(Type.SHORT); // 10 - Velocity Y
|
||||||
|
map(Type.SHORT); // 11 - Velocity Z
|
||||||
|
map(Types1_13.METADATA_LIST); // 12 - Metadata
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
|
||||||
|
EntityType entityType = EntityType1_13.getTypeFromId(type, false);
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
entityType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
MetaStorage storage = new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0));
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
storage
|
||||||
|
);
|
||||||
|
|
||||||
|
// Don't handle new ids / base meta since it's not used for this version
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
wrapper.set(
|
||||||
|
Types1_13.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
storage.getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn player packet
|
||||||
|
protocol.out(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Player UUID
|
||||||
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
map(Type.DOUBLE); // 3 - Y
|
||||||
|
map(Type.DOUBLE); // 4 - Z
|
||||||
|
map(Type.BYTE); // 5 - Yaw
|
||||||
|
map(Type.BYTE); // 6 - Pitch
|
||||||
|
map(Types1_13.METADATA_LIST); // 7 - Metadata
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.PLAYER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Rewrite Metadata
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.set(
|
||||||
|
Types1_13.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Spawn Painting
|
||||||
|
protocol.out(State.PLAY, 0x04, 0x04, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT);
|
||||||
|
map(Type.UUID);
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
EntityType.PAINTING
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Join Game
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Entity ID
|
||||||
|
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||||
|
map(Type.INT); // 2 - Dimension
|
||||||
|
|
||||||
|
// Track Entity
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
addTrackedEntity(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.INT, 0),
|
||||||
|
EntityType1_12.EntityType.PLAYER
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Save dimension
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||||
|
int dimensionId = wrapper.get(Type.INT, 1);
|
||||||
|
clientChunks.setEnvironment(dimensionId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Respawn
|
||||||
|
protocol.out(State.PLAY, 0x38, 0x38, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // 0 - Dimension ID\
|
||||||
|
|
||||||
|
// Save dimension
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Destroy entities
|
||||||
|
protocol.out(State.PLAY, 0x35, 0x35, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
|
||||||
|
getEntityTracker(wrapper.user()).removeEntity(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Metadata packet
|
||||||
|
protocol.out(State.PLAY, 0x3F, 0x3F, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Types1_13.METADATA_LIST); // 1 - Metadata list
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
wrapper.set(
|
||||||
|
Types1_13.METADATA_LIST,
|
||||||
|
0,
|
||||||
|
handleMeta(
|
||||||
|
wrapper.user(),
|
||||||
|
wrapper.get(Type.VAR_INT, 0),
|
||||||
|
new MetaStorage(wrapper.get(Types1_13.METADATA_LIST, 0))
|
||||||
|
).getMetaDataList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
|
||||||
|
// Rewrite items & blocks
|
||||||
|
registerMetaHandler().handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
|
if (meta.getMetaType() == MetaType1_13.Slot) {
|
||||||
|
InventoryPackets1_13_1.toClient((Item) meta.getValue());
|
||||||
|
} else if (meta.getMetaType() == MetaType1_13.BlockID) {
|
||||||
|
// Convert to new block id
|
||||||
|
int data = (int) meta.getValue();
|
||||||
|
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove shooter UUID
|
||||||
|
registerMetaHandler().
|
||||||
|
filter(EntityType.ABSTRACT_ARROW, true, 7)
|
||||||
|
.removed();
|
||||||
|
|
||||||
|
// Move colors to old position
|
||||||
|
registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8)
|
||||||
|
.handleIndexChange(7);
|
||||||
|
|
||||||
|
// Move loyalty level to old position
|
||||||
|
registerMetaHandler().filter(EntityType.TRIDENT, 8)
|
||||||
|
.handleIndexChange(7);
|
||||||
|
|
||||||
|
// Rewrite Minecart blocks
|
||||||
|
registerMetaHandler()
|
||||||
|
.filter(EntityType.MINECART_ABSTRACT, true, 9)
|
||||||
|
.handle(e -> {
|
||||||
|
Metadata meta = e.getData();
|
||||||
|
|
||||||
|
int data = (int) meta.getValue();
|
||||||
|
meta.setValue(Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||||
|
|
||||||
|
return meta;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
|
||||||
public class InventoryPackets {
|
public class InventoryPackets1_13_1 {
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol protocol) {
|
||||||
|
|
||||||
@ -16,30 +16,12 @@ public class InventoryPackets {
|
|||||||
Outgoing packets
|
Outgoing packets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Set slot packet
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.BYTE); // 0 - Window ID
|
|
||||||
map(Type.SHORT); // 1 - Slot ID
|
|
||||||
map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 2 - Slot Value
|
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
|
||||||
@Override
|
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
|
||||||
Item stack = wrapper.get(Type.FLAT_ITEM, 0);
|
|
||||||
toClient(stack);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Window items packet
|
// Window items packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||||
map(Type.FLAT_ITEM_ARRAY, Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
map(Type.FLAT_ITEM_ARRAY); // 1 - Window Values
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -52,13 +34,68 @@ public class InventoryPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set slot packet
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.BYTE); // 0 - Window ID
|
||||||
|
map(Type.SHORT); // 1 - Slot ID
|
||||||
|
map(Type.FLAT_ITEM); // 2 - Slot Value
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
Item stack = wrapper.get(Type.FLAT_ITEM, 0);
|
||||||
|
toClient(stack);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Plugin Message
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x19, 0x19, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
String channel = wrapper.passthrough(Type.STRING);
|
||||||
|
if (channel.equals("minecraft:trader_list")) {
|
||||||
|
wrapper.passthrough(Type.INT); //Passthrough Window ID
|
||||||
|
|
||||||
|
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
//Input Item
|
||||||
|
Item input = wrapper.passthrough(Type.FLAT_ITEM);
|
||||||
|
toClient(input);
|
||||||
|
//Output Item
|
||||||
|
Item output = wrapper.passthrough(Type.FLAT_ITEM);
|
||||||
|
toClient(input);
|
||||||
|
|
||||||
|
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); //Has second item
|
||||||
|
if (secondItem) {
|
||||||
|
//Second Item
|
||||||
|
Item second = wrapper.passthrough(Type.FLAT_ITEM);
|
||||||
|
toClient(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.BOOLEAN); //Trade disabled
|
||||||
|
wrapper.passthrough(Type.INT); //Number of tools uses
|
||||||
|
wrapper.passthrough(Type.INT); //Maximum number of trade uses
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Entity Equipment Packet
|
// Entity Equipment Packet
|
||||||
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.VAR_INT); // 0 - Entity ID
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
map(Type.VAR_INT); // 1 - Slot ID
|
map(Type.VAR_INT); // 1 - Slot ID
|
||||||
map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 2 - Item
|
map(Type.FLAT_ITEM); // 2 - Item
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -84,7 +121,7 @@ public class InventoryPackets {
|
|||||||
map(Type.BYTE); // 2 - Button
|
map(Type.BYTE); // 2 - Button
|
||||||
map(Type.SHORT); // 3 - Action number
|
map(Type.SHORT); // 3 - Action number
|
||||||
map(Type.VAR_INT); // 4 - Mode
|
map(Type.VAR_INT); // 4 - Mode
|
||||||
map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 5 - Clicked Item
|
map(Type.FLAT_ITEM); // 5 - Clicked Item
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
@ -102,7 +139,7 @@ public class InventoryPackets {
|
|||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.SHORT); // 0 - Slot
|
map(Type.SHORT); // 0 - Slot
|
||||||
map(Type.FLAT_ITEM, Type.FLAT_ITEM); // 1 - Clicked Item
|
map(Type.FLAT_ITEM); // 1 - Clicked Item
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
@ -13,7 +13,7 @@ import us.myles.ViaVersion.packets.State;
|
|||||||
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
public class WorldPackets {
|
public class WorldPackets1_13_1 {
|
||||||
|
|
||||||
public static void register(Protocol protocol) {
|
public static void register(Protocol protocol) {
|
||||||
//Chunk
|
//Chunk
|
||||||
@ -28,10 +28,10 @@ public class WorldPackets {
|
|||||||
|
|
||||||
for (ChunkSection section : chunk.getSections()) {
|
for (ChunkSection section : chunk.getSections()) {
|
||||||
if (section != null) {
|
if (section != null) {
|
||||||
for (int i = 0; i < section.getPalette().size(); i++) {
|
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||||
section.getPalette().set(
|
section.setPaletteEntry(
|
||||||
i,
|
i,
|
||||||
Protocol1_13To1_13_1.getNewBlockStateId(section.getPalette().get(i))
|
Protocol1_13To1_13_1.getNewBlockStateId(section.getPaletteEntry(i))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ public class WorldPackets {
|
|||||||
int id = wrapper.get(Type.INT, 0);
|
int id = wrapper.get(Type.INT, 0);
|
||||||
int data = wrapper.get(Type.INT, 1);
|
int data = wrapper.get(Type.INT, 1);
|
||||||
if (id == 1010) { // Play record
|
if (id == 1010) { // Play record
|
||||||
wrapper.set(Type.INT, 1, data = InventoryPackets.getNewItemId(data));
|
wrapper.set(Type.INT, 1, data = InventoryPackets1_13_1.getOldItemId(data));
|
||||||
} else if (id == 2001) { // Block break + block break sound
|
} else if (id == 2001) { // Block break + block break sound
|
||||||
wrapper.set(Type.INT, 1, data = Protocol1_13To1_13_1.getNewBlockStateId(data));
|
wrapper.set(Type.INT, 1, data = Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||||
}
|
}
|
||||||
@ -118,42 +118,6 @@ public class WorldPackets {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//join game
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x25, 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 {
|
|
||||||
// Store the player
|
|
||||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
|
||||||
int dimensionId = wrapper.get(Type.INT, 1);
|
|
||||||
clientChunks.setEnvironment(dimensionId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//respawn
|
|
||||||
protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() {
|
|
||||||
@Override
|
|
||||||
public void registerMap() {
|
|
||||||
map(Type.INT); // 0 - Dimension ID
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//spawn particle
|
//spawn particle
|
||||||
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() {
|
||||||
@Override
|
@Override
|
||||||
@ -175,6 +139,8 @@ public class WorldPackets {
|
|||||||
if(id == 3 || id == 20){
|
if(id == 3 || id == 20){
|
||||||
int data = wrapper.passthrough(Type.VAR_INT);
|
int data = wrapper.passthrough(Type.VAR_INT);
|
||||||
wrapper.set(Type.VAR_INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
wrapper.set(Type.VAR_INT, 0, Protocol1_13To1_13_1.getNewBlockStateId(data));
|
||||||
|
} else if (id == 27) {
|
||||||
|
InventoryPackets1_13_1.toClient(wrapper.passthrough(Type.FLAT_ITEM));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
|
public class Protocol1_14_1To1_14_2 extends BackwardsProtocol {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(UserConnection userConnection) {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
|
||||||
|
public class Protocol1_14_2To1_14_3 extends BackwardsProtocol {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets() {
|
||||||
|
// Trade list
|
||||||
|
registerOutgoing(State.PLAY, 0x27, 0x27, 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++) {
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
if (wrapper.passthrough(Type.BOOLEAN)) {
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
}
|
||||||
|
wrapper.passthrough(Type.BOOLEAN);
|
||||||
|
wrapper.passthrough(Type.INT);
|
||||||
|
wrapper.passthrough(Type.INT);
|
||||||
|
wrapper.passthrough(Type.INT);
|
||||||
|
wrapper.passthrough(Type.INT);
|
||||||
|
wrapper.passthrough(Type.FLOAT);
|
||||||
|
}
|
||||||
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
|
wrapper.passthrough(Type.VAR_INT);
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.BOOLEAN);
|
||||||
|
wrapper.read(Type.BOOLEAN);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Declare recipes
|
||||||
|
registerOutgoing(State.PLAY, 0x5A, 0x5A, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int size = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
int deleted = 0;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
String fullType = wrapper.read(Type.STRING);
|
||||||
|
String type = fullType.replace("minecraft:", "");
|
||||||
|
String id = wrapper.read(Type.STRING); // id
|
||||||
|
|
||||||
|
if (type.equals("crafting_special_repairitem")) {
|
||||||
|
deleted++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.write(Type.STRING, fullType);
|
||||||
|
wrapper.write(Type.STRING, id);
|
||||||
|
|
||||||
|
if (type.equals("crafting_shapeless")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||||
|
for (int j = 0; j < ingredientsNo; j++) {
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
}
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||||
|
} else if (type.equals("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++) {
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
}
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||||
|
} else if (type.equals("smelting")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
|
||||||
|
|
||||||
|
wrapper.passthrough(Type.FLOAT); // EXP
|
||||||
|
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||||
|
} else if (type.equals("stonecutting")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group?
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result
|
||||||
|
} else if (type.equals("blasting") || type.equals("campfire_cooking") || type.equals("smoking")) {
|
||||||
|
wrapper.passthrough(Type.STRING); // Group
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||||
|
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||||
|
wrapper.passthrough(Type.FLOAT); // EXP
|
||||||
|
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.set(Type.VAR_INT, 0, size - deleted);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(UserConnection userConnection) {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1;
|
||||||
|
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||||
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
|
||||||
|
*/
|
||||||
|
public class MetadataRewriter {
|
||||||
|
|
||||||
|
public static void handleMetadata(int entityId, Entity1_14Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
||||||
|
if (type == null) return;
|
||||||
|
|
||||||
|
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||||
|
try {
|
||||||
|
if (type.is(Entity1_14Types.EntityType.VILLAGER) || type.is(Entity1_14Types.EntityType.WANDERING_TRADER)) {
|
||||||
|
if (metadata.getId() >= 16) {
|
||||||
|
metadata.setId(metadata.getId() - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} 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,22 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1;
|
||||||
|
|
||||||
|
import nl.matsv.viabackwards.api.BackwardsProtocol;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.packets.EntityPackets;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.storage.EntityTracker;
|
||||||
|
import us.myles.ViaVersion.api.data.UserConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
|
||||||
|
*/
|
||||||
|
public class Protocol1_14To1_14_1 extends BackwardsProtocol {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets() {
|
||||||
|
EntityPackets.register(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(UserConnection userConnection) {
|
||||||
|
userConnection.put(new EntityTracker(userConnection));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,106 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.packets;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.MetadataRewriter;
|
||||||
|
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.storage.EntityTracker;
|
||||||
|
import us.myles.ViaVersion.api.PacketWrapper;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_14Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
|
||||||
|
*/
|
||||||
|
public class EntityPackets {
|
||||||
|
|
||||||
|
public static void register(Protocol protocol) {
|
||||||
|
|
||||||
|
// Spawn Mob
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Entity UUID
|
||||||
|
map(Type.VAR_INT); // 2 - Entity Type
|
||||||
|
map(Type.DOUBLE); // 3 - X
|
||||||
|
map(Type.DOUBLE); // 4 - Y
|
||||||
|
map(Type.DOUBLE); // 5 - Z
|
||||||
|
map(Type.BYTE); // 6 - Yaw
|
||||||
|
map(Type.BYTE); // 7 - Pitch
|
||||||
|
map(Type.BYTE); // 8 - Head Pitch
|
||||||
|
map(Type.SHORT); // 9 - Velocity X
|
||||||
|
map(Type.SHORT); // 10 - Velocity Y
|
||||||
|
map(Type.SHORT); // 11 - Velocity Z
|
||||||
|
map(Types1_14.METADATA_LIST); // 12 - Metadata
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
int type = wrapper.get(Type.VAR_INT, 1);
|
||||||
|
|
||||||
|
Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type);
|
||||||
|
|
||||||
|
// Register Type ID
|
||||||
|
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||||
|
|
||||||
|
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Spawn Player
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.VAR_INT); // 0 - Entity ID
|
||||||
|
map(Type.UUID); // 1 - Player UUID
|
||||||
|
map(Type.DOUBLE); // 2 - X
|
||||||
|
map(Type.DOUBLE); // 3 - Y
|
||||||
|
map(Type.DOUBLE); // 4 - Z
|
||||||
|
map(Type.BYTE); // 5 - Yaw
|
||||||
|
map(Type.BYTE); // 6 - Pitch
|
||||||
|
map(Types1_14.METADATA_LIST); // 7 - Metadata
|
||||||
|
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||||
|
|
||||||
|
Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER;
|
||||||
|
|
||||||
|
// Register Type ID
|
||||||
|
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
|
||||||
|
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Entity Metadata
|
||||||
|
protocol.registerOutgoing(State.PLAY, 0x43, 0x43, 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<EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId);
|
||||||
|
MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.storage;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
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_14Types;
|
||||||
|
import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
|
||||||
|
*/
|
||||||
|
public class EntityTracker extends StoredObject implements ExternalJoinGameListener {
|
||||||
|
private final Map<Integer, EntityType> clientEntityTypes = new ConcurrentHashMap<>();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private int clientEntityId;
|
||||||
|
|
||||||
|
public EntityTracker(UserConnection user) {
|
||||||
|
super(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEntity(int entityId) {
|
||||||
|
clientEntityTypes.remove(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEntity(int entityId, Entity1_14Types.EntityType type) {
|
||||||
|
clientEntityTypes.put(entityId, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean has(int entityId) {
|
||||||
|
return clientEntityTypes.containsKey(entityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<EntityType> get(int id) {
|
||||||
|
return Optional.fromNullable(clientEntityTypes.get(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onExternalJoinGame(int playerEntityId) {
|
||||||
|
clientEntityId = playerEntityId;
|
||||||
|
clientEntityTypes.put(playerEntityId, Entity1_14Types.EntityType.PLAYER);
|
||||||
|
}
|
||||||
|
}
|
@ -14,13 +14,14 @@ import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
|||||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||||
import nl.matsv.viabackwards.utils.Block;
|
import nl.matsv.viabackwards.utils.Block;
|
||||||
import us.myles.ViaVersion.api.PacketWrapper;
|
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.item.Item;
|
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
|
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10>
|
|||||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||||
|
|
||||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
|
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
|
||||||
Chunk1_9_3_4 chunk = (Chunk1_9_3_4) wrapper.passthrough(type);
|
Chunk chunk = wrapper.passthrough(type);
|
||||||
|
|
||||||
handleChunk(chunk);
|
handleChunk(chunk);
|
||||||
}
|
}
|
||||||
@ -199,18 +200,13 @@ public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10>
|
|||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
map(Type.INT); // 0 - Chunk X
|
map(Type.INT); // 0 - Chunk X
|
||||||
map(Type.INT); // 1 - Chunk Z
|
map(Type.INT); // 1 - Chunk Z
|
||||||
|
map(Type.BLOCK_CHANGE_RECORD_ARRAY);
|
||||||
|
|
||||||
handler(new PacketHandler() {
|
handler(new PacketHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void handle(PacketWrapper wrapper) throws Exception {
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
int count = wrapper.passthrough(Type.VAR_INT); // Array length
|
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||||
|
record.setBlockId(handleBlockID(record.getBlockId()));
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Horizontal position
|
|
||||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Y coords
|
|
||||||
|
|
||||||
int id = wrapper.read(Type.VAR_INT); // Block ID
|
|
||||||
wrapper.write(Type.VAR_INT, handleBlockID(id));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -234,7 +230,7 @@ public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10>
|
|||||||
rewrite(255).repItem(new Item((short) 166, (byte) 1, (short) 0, getNamedTag("1.10 Structure Block"))); // Structure block only item since the structure block is in 1.9
|
rewrite(255).repItem(new Item((short) 166, (byte) 1, (short) 0, getNamedTag("1.10 Structure Block"))); // Structure block only item since the structure block is in 1.9
|
||||||
rewrite(217).repItem(new Item((short) 287, (byte) 1, (short) 0, getNamedTag("1.10 Structure Void"))).repBlock(new Block(287, 0)); // Structure void to string
|
rewrite(217).repItem(new Item((short) 287, (byte) 1, (short) 0, getNamedTag("1.10 Structure Void"))).repBlock(new Block(287, 0)); // Structure void to string
|
||||||
rewrite(213).repItem(new Item((short) 159, (byte) 1, (short) 1, getNamedTag("1.10 Magma Block"))).repBlock(new Block(159, 1)); // Magma block to orange clay
|
rewrite(213).repItem(new Item((short) 159, (byte) 1, (short) 1, getNamedTag("1.10 Magma Block"))).repBlock(new Block(159, 1)); // Magma block to orange clay
|
||||||
rewrite(214).repItem(new Item((short) 159, (byte) 1, (short) 14, getNamedTag("1.10 Nether Ward Block"))).repBlock(new Block(159, 14)); // Nether wart block to red clay
|
rewrite(214).repItem(new Item((short) 159, (byte) 1, (short) 14, getNamedTag("1.10 Nether Ward Block"))).repBlock(new Block(159, 14)); // Nether ward block to red clay
|
||||||
rewrite(215).repItem(new Item((short) 112, (byte) 1, (short) 0, getNamedTag("1.10 Red Nether Bricks"))).repBlock(new Block(112, 0)); // Red nether brick to nether brick
|
rewrite(215).repItem(new Item((short) 112, (byte) 1, (short) 0, getNamedTag("1.10 Red Nether Bricks"))).repBlock(new Block(112, 0)); // Red nether brick to nether brick
|
||||||
rewrite(216).repItem(new Item((short) 155, (byte) 1, (short) 0, getNamedTag("1.10 Bone Block"))).repBlock(new Block(155, 0)); // Bone block to quartz
|
rewrite(216).repItem(new Item((short) 155, (byte) 1, (short) 0, getNamedTag("1.10 Bone Block"))).repBlock(new Block(155, 0)); // Bone block to quartz
|
||||||
}
|
}
|
||||||
|
32
core/src/main/java/nl/matsv/viabackwards/utils/ChatUtil.java
Normale Datei
32
core/src/main/java/nl/matsv/viabackwards/utils/ChatUtil.java
Normale Datei
@ -0,0 +1,32 @@
|
|||||||
|
package nl.matsv.viabackwards.utils;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class ChatUtil {
|
||||||
|
private static final Pattern UNUSED_COLOR_PATTERN = Pattern.compile("(?>(?>§[0-fk-or])*(§r|\\Z))|(?>(?>§[0-f])*(§[0-f]))");
|
||||||
|
private static final Pattern UNUSED_COLOR_PATTERN_PREFIX = Pattern.compile("(?>(?>§[0-fk-or])*(§r))|(?>(?>§[0-f])*(§[0-f]))");
|
||||||
|
|
||||||
|
public static String removeUnusedColor(String legacy, char defaultColor) {
|
||||||
|
return removeUnusedColor(legacy, defaultColor, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String removeUnusedColor(String legacy, char defaultColor, boolean isPrefix) {
|
||||||
|
if (legacy == null) return null;
|
||||||
|
Pattern pattern = isPrefix ? UNUSED_COLOR_PATTERN_PREFIX : UNUSED_COLOR_PATTERN;
|
||||||
|
legacy = pattern.matcher(legacy).replaceAll("$1$2");
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
char last = defaultColor;
|
||||||
|
for (int i = 0; i < legacy.length(); i++) {
|
||||||
|
char current = legacy.charAt(i);
|
||||||
|
if (current != '§' || i == legacy.length() - 1) {
|
||||||
|
builder.append(current);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
current = legacy.charAt(++i);
|
||||||
|
if (current == last) continue;
|
||||||
|
builder.append('§').append(current);
|
||||||
|
last = current;
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
}
|
5440
core/src/main/resources/assets/viabackwards/data/mapping-1.12.2to1.13.json
Normale Datei
5440
core/src/main/resources/assets/viabackwards/data/mapping-1.12.2to1.13.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
2662
core/src/main/resources/assets/viabackwards/data/mapping-1.13.2to1.14.json
Normale Datei
2662
core/src/main/resources/assets/viabackwards/data/mapping-1.13.2to1.14.json
Normale Datei
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
63
fabric/pom.xml
Normale Datei
63
fabric/pom.xml
Normale Datei
@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016 Matsv
|
||||||
|
~
|
||||||
|
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
~
|
||||||
|
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
~
|
||||||
|
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>viabackwards-fabric</artifactId>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>fabric-repo</id>
|
||||||
|
<url>https://maven.fabricmc.net/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.fabricmc</groupId>
|
||||||
|
<artifactId>fabric-loader</artifactId>
|
||||||
|
<version>0.4.8+build.154</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.8.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<artifactId>viabackwards-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>.</targetPath>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/main/resources/</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
</project>
|
34
fabric/src/main/java/nl/matsv/viabackwards/ViaFabricAddon.java
Normale Datei
34
fabric/src/main/java/nl/matsv/viabackwards/ViaFabricAddon.java
Normale Datei
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||||
|
import nl.matsv.viabackwards.fabric.util.LoggerWrapper;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable {
|
||||||
|
@Getter
|
||||||
|
private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaRewind"));
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
// Not possible
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.fabric.util;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.LogRecord;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
public class LoggerWrapper extends Logger {
|
||||||
|
private final org.apache.logging.log4j.Logger base;
|
||||||
|
|
||||||
|
public LoggerWrapper(org.apache.logging.log4j.Logger logger) {
|
||||||
|
super("logger", null);
|
||||||
|
this.base = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(LogRecord record) {
|
||||||
|
this.log(record.getLevel(), record.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(Level level, String msg) {
|
||||||
|
if (level == Level.FINE) {
|
||||||
|
this.base.debug(msg);
|
||||||
|
} else if (level == Level.WARNING) {
|
||||||
|
this.base.warn(msg);
|
||||||
|
} else if (level == Level.SEVERE) {
|
||||||
|
this.base.error(msg);
|
||||||
|
} else if (level == Level.INFO) {
|
||||||
|
this.base.info(msg);
|
||||||
|
} else {
|
||||||
|
this.base.trace(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(Level level, String msg, Object param1) {
|
||||||
|
if (level == Level.FINE) {
|
||||||
|
this.base.debug(msg, param1);
|
||||||
|
} else if (level == Level.WARNING) {
|
||||||
|
this.base.warn(msg, param1);
|
||||||
|
} else if (level == Level.SEVERE) {
|
||||||
|
this.base.error(msg, param1);
|
||||||
|
} else if (level == Level.INFO) {
|
||||||
|
this.base.info(msg, param1);
|
||||||
|
} else {
|
||||||
|
this.base.trace(msg, param1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(Level level, String msg, Object[] params) {
|
||||||
|
log(level, MessageFormat.format(msg, params));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(Level level, String msg, Throwable params) {
|
||||||
|
if (level == Level.FINE) {
|
||||||
|
this.base.debug(msg, params);
|
||||||
|
} else if (level == Level.WARNING) {
|
||||||
|
this.base.warn(msg, params);
|
||||||
|
} else if (level == Level.SEVERE) {
|
||||||
|
this.base.error(msg, params);
|
||||||
|
} else if (level == Level.INFO) {
|
||||||
|
this.base.info(msg, params);
|
||||||
|
} else {
|
||||||
|
this.base.trace(msg, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
29
fabric/src/main/resources/fabric.mod.json
Normale Datei
29
fabric/src/main/resources/fabric.mod.json
Normale Datei
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"schemaVersion": 1,
|
||||||
|
"id": "viabackwards",
|
||||||
|
"name": "ViaBackwards",
|
||||||
|
"version": "${project.version}",
|
||||||
|
"description": "Allow older Minecraft versions to connect to a newer server version.",
|
||||||
|
"license": "MIT",
|
||||||
|
"contact": {
|
||||||
|
"homepage": "https://github.com/ViaVersion/ViaBackwards",
|
||||||
|
"issues": "https://github.com/ViaVersion/ViaBackwards/issues",
|
||||||
|
"sources": "https://github.com/ViaVersion/ViaBackwards"
|
||||||
|
},
|
||||||
|
"environment": "*",
|
||||||
|
"authors": [
|
||||||
|
"Matsv"
|
||||||
|
],
|
||||||
|
"entrypoints": {
|
||||||
|
"viafabric:via_api_initialized": [
|
||||||
|
"nl.matsv.viabackwards.ViaFabricAddon"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"depends": {
|
||||||
|
"fabricloader": ">=0.4.0",
|
||||||
|
"viafabric": "*"
|
||||||
|
},
|
||||||
|
"recommends": {
|
||||||
|
"viarewind": "*"
|
||||||
|
}
|
||||||
|
}
|
12
pom.xml
12
pom.xml
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<groupId>nl.matsv</groupId>
|
<groupId>nl.matsv</groupId>
|
||||||
<artifactId>viabackwards-parent</artifactId>
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<description>Allow newer clients to join older server versions.</description>
|
<description>Allow newer clients to join older server versions.</description>
|
||||||
@ -27,7 +27,9 @@
|
|||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>bukkit</module>
|
<module>bukkit</module>
|
||||||
<module>bungee</module>
|
<module>bungee</module>
|
||||||
|
<module>fabric</module>
|
||||||
<module>sponge</module>
|
<module>sponge</module>
|
||||||
|
<module>velocity</module>
|
||||||
<module>all</module>
|
<module>all</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
@ -55,17 +57,11 @@
|
|||||||
<version>1.16.18</version>
|
<version>1.16.18</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Guava -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<version>19.0</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- ViaVersion -->
|
<!-- ViaVersion -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>us.myles</groupId>
|
<groupId>us.myles</groupId>
|
||||||
<artifactId>viaversion</artifactId>
|
<artifactId>viaversion</artifactId>
|
||||||
<version>1.6.0</version>
|
<version>2.1.2</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>viabackwards-parent</artifactId>
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
<groupId>nl.matsv</groupId>
|
<groupId>nl.matsv</groupId>
|
||||||
<version>2.4.0-SNAPSHOT</version>
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
package nl.matsv.viabackwards;
|
package nl.matsv.viabackwards;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import lombok.Getter;
|
||||||
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||||
import nl.matsv.viabackwards.sponge.VersionInfo;
|
import nl.matsv.viabackwards.sponge.VersionInfo;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.Order;
|
import org.spongepowered.api.event.Order;
|
||||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
import org.spongepowered.api.event.game.state.GameInitializationEvent;
|
||||||
import org.spongepowered.api.plugin.Dependency;
|
import org.spongepowered.api.plugin.Dependency;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
import org.spongepowered.api.plugin.PluginContainer;
|
|
||||||
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -27,30 +27,25 @@ import java.util.logging.Logger;
|
|||||||
name = "ViaBackwards",
|
name = "ViaBackwards",
|
||||||
version = VersionInfo.VERSION,
|
version = VersionInfo.VERSION,
|
||||||
authors = {"Matsv"},
|
authors = {"Matsv"},
|
||||||
description = "Allow older Minecraft versions to connect to an newer server version.",
|
description = "Allow older Minecraft versions to connect to a newer server version.",
|
||||||
dependencies = {@Dependency(id = "viaversion")}
|
dependencies = {@Dependency(id = "viaversion")}
|
||||||
)
|
)
|
||||||
public class SpongePlugin implements ViaBackwardsPlatform {
|
public class SpongePlugin implements ViaBackwardsPlatform {
|
||||||
|
@Getter
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
@Inject
|
@Inject
|
||||||
private PluginContainer container;
|
private org.slf4j.Logger loggerSlf4j;
|
||||||
|
|
||||||
@Listener(order = Order.LATE)
|
@Listener(order = Order.LATE)
|
||||||
public void onServerStart(GameAboutToStartServerEvent e) {
|
public void onGameStart(GameInitializationEvent e) {
|
||||||
// Setup Logger
|
// Setup Logger
|
||||||
this.logger = new LoggerWrapper(container.getLogger());
|
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||||
// Init!
|
// Init!
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Logger getLogger() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO check how to for sponge, site was offline
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
public void disable() {
|
||||||
|
// Not possible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
83
velocity/pom.xml
Normale Datei
83
velocity/pom.xml
Normale Datei
@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016 Matsv
|
||||||
|
~
|
||||||
|
~ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
~
|
||||||
|
~ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
~
|
||||||
|
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>viabackwards-parent</artifactId>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<version>3.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>viabackwards-velocity</artifactId>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<targetPath>.</targetPath>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/main/resources/</directory>
|
||||||
|
<includes>
|
||||||
|
<include>*</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<!-- Stolen from ViaVersion ;) -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>templating-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>filter-src</id>
|
||||||
|
<goals>
|
||||||
|
<goal>filter-sources</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>velocity-maven-repo</id>
|
||||||
|
<name>Velocity maven repo</name>
|
||||||
|
<url>https://repo.velocitypowered.com/snapshots/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- Common Module -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>nl.matsv</groupId>
|
||||||
|
<artifactId>viabackwards-core</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Velocity API -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
<artifactId>velocity-api</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards.velocity;
|
||||||
|
|
||||||
|
public class VersionInfo {
|
||||||
|
public static final String VERSION = "${project.version}";
|
||||||
|
}
|
51
velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java
Normale Datei
51
velocity/src/main/java/nl/matsv/viabackwards/VelocityPlugin.java
Normale Datei
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 Matsv
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package nl.matsv.viabackwards;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
|
import com.velocitypowered.api.plugin.Dependency;
|
||||||
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
|
import lombok.Getter;
|
||||||
|
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
|
||||||
|
import nl.matsv.viabackwards.velocity.VersionInfo;
|
||||||
|
import us.myles.ViaVersion.sponge.util.LoggerWrapper;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@Plugin(id = "viabackwards",
|
||||||
|
name = "ViaBackwards",
|
||||||
|
version = VersionInfo.VERSION,
|
||||||
|
authors = {"Matsv"},
|
||||||
|
description = "Allow older Minecraft versions to connect to a newer server version.",
|
||||||
|
dependencies = {@Dependency(id = "viaversion")}
|
||||||
|
)
|
||||||
|
public class VelocityPlugin implements ViaBackwardsPlatform {
|
||||||
|
@Getter
|
||||||
|
private Logger logger;
|
||||||
|
@Inject
|
||||||
|
private org.slf4j.Logger loggerSlf4j;
|
||||||
|
|
||||||
|
@Subscribe(order = PostOrder.LATE)
|
||||||
|
public void onProxyStart(ProxyInitializeEvent e) {
|
||||||
|
// Setup Logger
|
||||||
|
this.logger = new LoggerWrapper(loggerSlf4j);
|
||||||
|
// Init!
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable() {
|
||||||
|
// Not possible
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren