Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 00:50:13 +01:00
20w17a, update entity types renamed in 1.13
Dieser Commit ist enthalten in:
Ursprung
c7bc9aa43c
Commit
e22bba0360
@ -35,12 +35,12 @@ public class Entity1_13Types {
|
||||
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
|
||||
END_CRYSTAL(16, ENTITY), // aho
|
||||
EVOKER_FANGS(20, ENTITY), // ala
|
||||
EXPERIENCE_ORB(22, ENTITY), // abs
|
||||
EYE_OF_ENDER(23, ENTITY), // alb
|
||||
FALLING_BLOCK(24, ENTITY), // aix
|
||||
FIREWORKS_ROCKET(25, ENTITY), // alc
|
||||
FIREWORK_ROCKET(25, ENTITY), // alc
|
||||
ITEM(32, ENTITY), // aiy
|
||||
LLAMA_SPIT(37, ENTITY), // ale
|
||||
TNT(55, ENTITY), // aiz
|
||||
@ -89,15 +89,15 @@ public class Entity1_13Types {
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE), // agc
|
||||
SNOWMAN(66, ABSTRACT_GOLEM), // ags
|
||||
VILLAGER_GOLEM(80, ABSTRACT_GOLEM), // agw
|
||||
SNOW_GOLEM(66, ABSTRACT_GOLEM), // ags
|
||||
IRON_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
|
||||
PUFFERFISH(52, ABSTRACT_FISHES), // agn
|
||||
SALMON(57, ABSTRACT_FISHES), // agp
|
||||
TROPICAL_FISH(72, ABSTRACT_FISHES), // agu
|
||||
|
||||
|
||||
@ -116,9 +116,9 @@ public class Entity1_13Types {
|
||||
// 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
|
||||
EVOKER(21, ABSTRACT_EVO_ILLU_ILLAGER), // ajl
|
||||
ILLUSIONER(31, ABSTRACT_EVO_ILLU_ILLAGER), // ajq
|
||||
VINDICATOR(81, ABSTRACT_ILLAGER_BASE), // akf
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER), // ajc
|
||||
@ -185,7 +185,7 @@ public class Entity1_13Types {
|
||||
ENDER_PEARL(75, PROJECTILE_ABSTRACT), // aln
|
||||
EGG(74, PROJECTILE_ABSTRACT), // alm
|
||||
POTION(77, PROJECTILE_ABSTRACT), // alp
|
||||
XP_BOTTLE(76, PROJECTILE_ABSTRACT), // alo
|
||||
EXPERIENCE_BOTTLE(76, PROJECTILE_ABSTRACT), // alo
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY), // alt
|
||||
@ -194,7 +194,7 @@ public class Entity1_13Types {
|
||||
HOPPER_MINECART(43, CHESTED_MINECART_ABSTRACT), // ama
|
||||
MINECART(39, MINECART_ABSTRACT), // alw
|
||||
FURNACE_MINECART(42, MINECART_ABSTRACT), // alz
|
||||
COMMANDBLOCK_MINECART(41, MINECART_ABSTRACT), // aly
|
||||
COMMAND_BLOCK_MINECART(41, MINECART_ABSTRACT), // aly
|
||||
TNT_MINECART(45, MINECART_ABSTRACT), // amc
|
||||
SPAWNER_MINECART(44, MINECART_ABSTRACT), // amb
|
||||
BOAT(5, ENTITY); // alv
|
||||
@ -230,7 +230,7 @@ public class Entity1_13Types {
|
||||
AREA_EFFECT_CLOUD(3, EntityType.AREA_EFFECT_CLOUD),
|
||||
MINECART(10, EntityType.MINECART),
|
||||
TNT_PRIMED(50, EntityType.TNT),
|
||||
ENDER_CRYSTAL(51, EntityType.ENDER_CRYSTAL),
|
||||
ENDER_CRYSTAL(51, EntityType.END_CRYSTAL),
|
||||
TIPPED_ARROW(60, EntityType.ARROW),
|
||||
SNOWBALL(61, EntityType.SNOWBALL),
|
||||
EGG(62, EntityType.EGG),
|
||||
@ -242,13 +242,13 @@ public class Entity1_13Types {
|
||||
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),
|
||||
EYE_OF_ENDER(72, EntityType.EYE_OF_ENDER),
|
||||
POTION(73, EntityType.POTION),
|
||||
THROWN_EXP_BOTTLE(75, EntityType.XP_BOTTLE),
|
||||
FIREWORK(76, EntityType.FIREWORKS_ROCKET),
|
||||
EXPERIENCE_BOTTLE(75, EntityType.EXPERIENCE_BOTTLE),
|
||||
FIREWORK_ROCKET(76, EntityType.FIREWORK_ROCKET),
|
||||
LEASH(77, EntityType.LEASH_KNOT),
|
||||
ARMOR_STAND(78, EntityType.ARMOR_STAND),
|
||||
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
|
||||
EVOKER_FANGS(79, EntityType.EVOKER_FANGS),
|
||||
FISHIHNG_HOOK(90, EntityType.FISHING_BOBBER),
|
||||
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
|
||||
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
|
||||
|
@ -30,12 +30,12 @@ public class Entity1_14Types {
|
||||
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),
|
||||
END_CRYSTAL(17, ENTITY),
|
||||
EVOKER_FANGS(21, ENTITY),
|
||||
EXPERIENCE_ORB(23, ENTITY),
|
||||
EYE_OF_ENDER(24, ENTITY),
|
||||
FALLING_BLOCK(25, ENTITY),
|
||||
FIREWORKS_ROCKET(26, ENTITY),
|
||||
FIREWORK_ROCKET(26, ENTITY),
|
||||
ITEM(34, ENTITY),
|
||||
LLAMA_SPIT(39, ENTITY),
|
||||
TNT(58, ENTITY),
|
||||
@ -90,15 +90,15 @@ public class Entity1_14Types {
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOWMAN(69, ABSTRACT_GOLEM),
|
||||
VILLAGER_GOLEM(85, ABSTRACT_GOLEM),
|
||||
SNOW_GOLEM(69, ABSTRACT_GOLEM),
|
||||
IRON_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),
|
||||
PUFFERFISH(55, ABSTRACT_FISHES),
|
||||
SALMON(60, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(76, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
@ -117,9 +117,9 @@ public class Entity1_14Types {
|
||||
// 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),
|
||||
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(33, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(86, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(87, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
@ -186,7 +186,7 @@ public class Entity1_14Types {
|
||||
ENDER_PEARL(79, PROJECTILE_ABSTRACT),
|
||||
EGG(78, PROJECTILE_ABSTRACT),
|
||||
POTION(81, PROJECTILE_ABSTRACT),
|
||||
XP_BOTTLE(80, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(80, PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
@ -195,7 +195,7 @@ public class Entity1_14Types {
|
||||
HOPPER_MINECART(45, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(41, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(44, MINECART_ABSTRACT),
|
||||
COMMANDBLOCK_MINECART(43, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(43, MINECART_ABSTRACT),
|
||||
TNT_MINECART(47, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(46, MINECART_ABSTRACT),
|
||||
BOAT(5, ENTITY),
|
||||
|
@ -29,12 +29,12 @@ public class Entity1_15Types {
|
||||
ENTITY(-1),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
ENDER_CRYSTAL(18, ENTITY),
|
||||
EVOCATION_FANGS(22, ENTITY),
|
||||
XP_ORB(24, ENTITY),
|
||||
EYE_OF_ENDER_SIGNAL(25, ENTITY),
|
||||
END_CRYSTAL(18, ENTITY),
|
||||
EVOKER_FANGS(22, ENTITY),
|
||||
EXPERIENCE_ORB(24, ENTITY),
|
||||
EYE_OF_ENDER(25, ENTITY),
|
||||
FALLING_BLOCK(26, ENTITY),
|
||||
FIREWORKS_ROCKET(27, ENTITY),
|
||||
FIREWORK_ROCKET(27, ENTITY),
|
||||
ITEM(35, ENTITY),
|
||||
LLAMA_SPIT(40, ENTITY),
|
||||
TNT(59, ENTITY),
|
||||
@ -91,15 +91,15 @@ public class Entity1_15Types {
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOWMAN(70, ABSTRACT_GOLEM),
|
||||
VILLAGER_GOLEM(86, ABSTRACT_GOLEM),
|
||||
SNOW_GOLEM(70, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(86, ABSTRACT_GOLEM),
|
||||
SHULKER(63, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(10, ABSTRACT_FISHES),
|
||||
PUFFER_FISH(56, ABSTRACT_FISHES),
|
||||
SALMON_MOB(61, ABSTRACT_FISHES),
|
||||
PUFFERFISH(56, ABSTRACT_FISHES),
|
||||
SALMON(61, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(77, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
@ -118,9 +118,9 @@ public class Entity1_15Types {
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOCATION_ILLAGER(23, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSION_ILLAGER(34, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATION_ILLAGER(87, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(34, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(87, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(88, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
@ -187,7 +187,7 @@ public class Entity1_15Types {
|
||||
ENDER_PEARL(80, PROJECTILE_ABSTRACT),
|
||||
EGG(79, PROJECTILE_ABSTRACT),
|
||||
POTION(82, PROJECTILE_ABSTRACT),
|
||||
XP_BOTTLE(81, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(81, PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
@ -196,7 +196,7 @@ public class Entity1_15Types {
|
||||
HOPPER_MINECART(46, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(42, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(45, MINECART_ABSTRACT),
|
||||
COMMANDBLOCK_MINECART(44, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(44, MINECART_ABSTRACT),
|
||||
TNT_MINECART(48, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(47, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
|
@ -30,15 +30,15 @@ public class Entity1_16Types {
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
END_CRYSTAL(18, ENTITY),
|
||||
EVOKER_FANGS(22, ENTITY),
|
||||
EVOKER_FANGS(23, ENTITY),
|
||||
EXPERIENCE_ORB(24, ENTITY),
|
||||
EYE_OF_ENDER(25, ENTITY),
|
||||
FALLING_BLOCK(26, ENTITY),
|
||||
FIREWORK_ROCKET(27, ENTITY),
|
||||
ITEM(35, ENTITY),
|
||||
LLAMA_SPIT(40, ENTITY),
|
||||
TNT(58, ENTITY),
|
||||
SHULKER_BULLET(63, ENTITY),
|
||||
ITEM(37, ENTITY),
|
||||
LLAMA_SPIT(42, ENTITY),
|
||||
TNT(62, ENTITY),
|
||||
SHULKER_BULLET(69, ENTITY),
|
||||
FISHING_BOBBER(106, ENTITY),
|
||||
|
||||
LIVINGENTITY(-1, ENTITY),
|
||||
@ -53,54 +53,54 @@ public class Entity1_16Types {
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||
VILLAGER(84, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(88, ABSTRACT_AGEABLE),
|
||||
VILLAGER(91, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(93, ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||
DOLPHIN(14, ABSTRACT_INSENTIENT),
|
||||
DOLPHIN(13, ABSTRACT_INSENTIENT),
|
||||
CHICKEN(9, ABSTRACT_ANIMAL),
|
||||
COW(11, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(50, COW),
|
||||
PANDA(53, ABSTRACT_INSENTIENT),
|
||||
PIG(55, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(57, ABSTRACT_ANIMAL),
|
||||
RABBIT(59, ABSTRACT_ANIMAL),
|
||||
SHEEP(61, ABSTRACT_ANIMAL),
|
||||
TURTLE(77, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(52, COW),
|
||||
PANDA(55, ABSTRACT_INSENTIENT),
|
||||
PIG(58, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(61, ABSTRACT_ANIMAL),
|
||||
RABBIT(64, ABSTRACT_ANIMAL),
|
||||
SHEEP(67, ABSTRACT_ANIMAL),
|
||||
TURTLE(89, ABSTRACT_ANIMAL),
|
||||
FOX(28, ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(51, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(93, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(53, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(98, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
PARROT(54, ABSTRACT_PARROT),
|
||||
PARROT(56, ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
DONKEY(13, CHESTED_HORSE),
|
||||
MULE(49, CHESTED_HORSE),
|
||||
LLAMA(39, CHESTED_HORSE),
|
||||
TRADER_LLAMA(75, CHESTED_HORSE),
|
||||
HORSE(32, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(66, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(96, ABSTRACT_HORSE),
|
||||
DONKEY(14, CHESTED_HORSE),
|
||||
MULE(51, CHESTED_HORSE),
|
||||
LLAMA(41, CHESTED_HORSE),
|
||||
TRADER_LLAMA(87, CHESTED_HORSE),
|
||||
HORSE(33, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(72, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(101, ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOW_GOLEM(69, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(85, ABSTRACT_GOLEM),
|
||||
SHULKER(62, ABSTRACT_GOLEM),
|
||||
SNOW_GOLEM(75, ABSTRACT_GOLEM),
|
||||
IRON_GOLEM(36, ABSTRACT_GOLEM),
|
||||
SHULKER(68, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(10, ABSTRACT_FISHES),
|
||||
PUFFERFISH(56, ABSTRACT_FISHES),
|
||||
SALMON(60, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(76, ABSTRACT_FISHES),
|
||||
PUFFERFISH(63, ABSTRACT_FISHES),
|
||||
SALMON(66, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(88, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||
@ -109,66 +109,66 @@ public class Entity1_16Types {
|
||||
ENDERMITE(21, ABSTRACT_MONSTER),
|
||||
ENDERMAN(20, ABSTRACT_MONSTER),
|
||||
GIANT(30, ABSTRACT_MONSTER),
|
||||
SILVERFISH(64, ABSTRACT_MONSTER),
|
||||
VEX(83, ABSTRACT_MONSTER),
|
||||
WITCH(89, ABSTRACT_MONSTER),
|
||||
WITHER(90, ABSTRACT_MONSTER),
|
||||
RAVAGER(99, ABSTRACT_MONSTER),
|
||||
PIGLIN(101, ABSTRACT_MONSTER),
|
||||
SILVERFISH(70, ABSTRACT_MONSTER),
|
||||
VEX(90, ABSTRACT_MONSTER),
|
||||
WITCH(94, ABSTRACT_MONSTER),
|
||||
WITHER(95, ABSTRACT_MONSTER),
|
||||
RAVAGER(65, ABSTRACT_MONSTER),
|
||||
PIGLIN(59, ABSTRACT_MONSTER),
|
||||
|
||||
HOGLIN(100, ABSTRACT_ANIMAL),
|
||||
STRIDER(102, ABSTRACT_ANIMAL),
|
||||
ZOGLIN(103, ABSTRACT_MONSTER),
|
||||
HOGLIN(32, ABSTRACT_ANIMAL),
|
||||
STRIDER(81, ABSTRACT_ANIMAL),
|
||||
ZOGLIN(99, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(23, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(34, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(86, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(87, ABSTRACT_ILLAGER_BASE),
|
||||
EVOKER(22, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSIONER(35, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATOR(92, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(60, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||
SKELETON(65, ABSTRACT_SKELETON),
|
||||
STRAY(74, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(91, ABSTRACT_SKELETON),
|
||||
SKELETON(71, ABSTRACT_SKELETON),
|
||||
STRAY(80, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(96, ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(31, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(17, GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(72, ABSTRACT_MONSTER),
|
||||
SPIDER(78, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(8, SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(94, ABSTRACT_MONSTER),
|
||||
ZOMBIE(100, ABSTRACT_MONSTER),
|
||||
DROWNED(16, ZOMBIE),
|
||||
HUSK(33, ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(95, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(97, ZOMBIE),
|
||||
HUSK(34, ZOMBIE),
|
||||
ZOMBIFIED_PIGLIN(103, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(102, ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||
GHAST(29, ABSTRACT_FLYING),
|
||||
PHANTOM(98, ABSTRACT_FLYING),
|
||||
PHANTOM(57, ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||
BAT(3, ABSTRACT_AMBIENT),
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||
SQUID(73, ABSTRACT_WATERMOB),
|
||||
SQUID(79, ABSTRACT_WATERMOB),
|
||||
|
||||
// Slimes
|
||||
SLIME(67, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(41, SLIME),
|
||||
SLIME(73, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(43, SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY),
|
||||
LEASH_KNOT(38, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(36, ABSTRACT_HANGING),
|
||||
PAINTING(52, ABSTRACT_HANGING),
|
||||
LEASH_KNOT(40, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(38, ABSTRACT_HANGING),
|
||||
PAINTING(54, ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||
LIGHTNING_BOLT(104, ABSTRACT_LIGHTNING),
|
||||
@ -176,34 +176,34 @@ public class Entity1_16Types {
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(71, ABSTRACT_ARROW),
|
||||
TRIDENT(82, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(77, ABSTRACT_ARROW),
|
||||
TRIDENT(86, ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
|
||||
FIREBALL(37, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(68, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(92, ABSTRACT_FIREBALL),
|
||||
FIREBALL(39, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(74, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(97, ABSTRACT_FIREBALL),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||
SNOWBALL(70, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(79, PROJECTILE_ABSTRACT),
|
||||
EGG(78, PROJECTILE_ABSTRACT),
|
||||
POTION(81, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(80, PROJECTILE_ABSTRACT),
|
||||
SNOWBALL(76, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(83, PROJECTILE_ABSTRACT),
|
||||
EGG(82, PROJECTILE_ABSTRACT),
|
||||
POTION(85, PROJECTILE_ABSTRACT),
|
||||
EXPERIENCE_BOTTLE(84, PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(43, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(46, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(42, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(45, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(44, MINECART_ABSTRACT),
|
||||
TNT_MINECART(48, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(47, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(45, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(48, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(44, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(47, MINECART_ABSTRACT),
|
||||
COMMAND_BLOCK_MINECART(46, MINECART_ABSTRACT),
|
||||
TNT_MINECART(50, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(49, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
@ -6,6 +6,8 @@ public interface EntityType {
|
||||
|
||||
EntityType getParent();
|
||||
|
||||
String name();
|
||||
|
||||
default boolean is(EntityType... types) {
|
||||
for (EntityType type : types)
|
||||
if (is(type))
|
||||
|
@ -80,7 +80,7 @@ public class ProtocolVersion {
|
||||
register(v1_15 = new ProtocolVersion(573, "1.15"));
|
||||
register(v1_15_1 = new ProtocolVersion(575, "1.15.1"));
|
||||
register(v1_15_2 = new ProtocolVersion(578, "1.15.2"));
|
||||
register(v1_16 = new ProtocolVersion(712, "1.16"));
|
||||
register(v1_16 = new ProtocolVersion(713, "1.16"));
|
||||
|
||||
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import java.util.logging.Logger;
|
||||
public abstract class MetadataRewriter {
|
||||
private final Class<? extends EntityTracker> entityTrackerClass;
|
||||
private final Protocol protocol;
|
||||
private Map<Integer, Integer> typeMapping;
|
||||
|
||||
protected MetadataRewriter(Protocol protocol, Class<? extends EntityTracker> entityTrackerClass) {
|
||||
this.protocol = protocol;
|
||||
@ -175,6 +176,26 @@ public abstract class MetadataRewriter {
|
||||
registerMetadataRewriter(oldPacketId, newPacketId, null, metaType);
|
||||
}
|
||||
|
||||
public <T extends Enum<T> & EntityType> void mapTypes(EntityType[] oldTypes, Class<T> newTypeClass) {
|
||||
if (typeMapping == null) typeMapping = new HashMap<>(oldTypes.length);
|
||||
for (EntityType oldType : oldTypes) {
|
||||
try {
|
||||
T newType = Enum.valueOf(newTypeClass, oldType.name());
|
||||
typeMapping.put(oldType.getId(), newType.getId());
|
||||
} catch (IllegalArgumentException notFound) {
|
||||
if (!typeMapping.containsKey(oldType.getId())) {
|
||||
Via.getPlatform().getLogger().warning("Could not find new entity type for " + oldType + "! " +
|
||||
"Old type: " + oldType.getClass().getSimpleName() + " New type: " + newTypeClass.getSimpleName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mapType(EntityType oldType, EntityType newType) {
|
||||
if (typeMapping == null) typeMapping = new HashMap<>();
|
||||
typeMapping.put(oldType.getId(), newType.getId());
|
||||
}
|
||||
|
||||
public PacketHandler getTracker() {
|
||||
return getTrackerAndRewriter(null);
|
||||
}
|
||||
@ -243,7 +264,7 @@ public abstract class MetadataRewriter {
|
||||
}
|
||||
|
||||
public int getNewEntityId(int oldId) {
|
||||
return oldId;
|
||||
return typeMapping != null ? typeMapping.getOrDefault(oldId, oldId) : oldId;
|
||||
}
|
||||
|
||||
protected void handleMetadata(int entityId, EntityType type, Metadata metadata, List<Metadata> metadatas, UserConnection connection) throws Exception {
|
||||
|
@ -0,0 +1,80 @@
|
||||
package us.myles.ViaVersion.api.type.types.version;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.util.CompactArrayUtil;
|
||||
|
||||
public class ChunkSectionType1_16 extends Type<ChunkSection> {
|
||||
private static final int GLOBAL_PALETTE = 14;
|
||||
|
||||
public ChunkSectionType1_16() {
|
||||
super("Chunk Section Type", ChunkSection.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkSection read(ByteBuf buffer) throws Exception {
|
||||
ChunkSection chunkSection = new ChunkSection();
|
||||
|
||||
// Reaad bits per block
|
||||
int bitsPerBlock = buffer.readUnsignedByte();
|
||||
int originalBitsPerBlock = bitsPerBlock;
|
||||
|
||||
if (bitsPerBlock == 0 || bitsPerBlock > 8) {
|
||||
bitsPerBlock = GLOBAL_PALETTE;
|
||||
}
|
||||
|
||||
int paletteLength = bitsPerBlock == GLOBAL_PALETTE ? 0 : Type.VAR_INT.read(buffer);
|
||||
// Read palette
|
||||
chunkSection.clearPalette();
|
||||
for (int i = 0; i < paletteLength; i++) {
|
||||
chunkSection.addPaletteEntry(Type.VAR_INT.read(buffer));
|
||||
}
|
||||
|
||||
// Read blocks
|
||||
long[] blockData = new long[Type.VAR_INT.read(buffer)];
|
||||
if (blockData.length > 0) {
|
||||
int expectedLength = (int) Math.ceil(ChunkSection.SIZE * bitsPerBlock / 64.0);
|
||||
if (blockData.length != expectedLength) {
|
||||
throw new IllegalStateException("Block data length (" + blockData.length + ") does not match expected length (" + expectedLength + ")! bitsPerBlock=" + bitsPerBlock + ", originalBitsPerBlock=" + originalBitsPerBlock);
|
||||
}
|
||||
|
||||
for (int i = 0; i < blockData.length; i++) {
|
||||
blockData[i] = buffer.readLong();
|
||||
}
|
||||
CompactArrayUtil.iterateCompactArrayWithPadding(bitsPerBlock, ChunkSection.SIZE, blockData,
|
||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::setFlatBlock : chunkSection::setPaletteIndex);
|
||||
}
|
||||
|
||||
return chunkSection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, ChunkSection chunkSection) throws Exception {
|
||||
int bitsPerBlock = 4;
|
||||
while (chunkSection.getPaletteSize() > 1 << bitsPerBlock) {
|
||||
bitsPerBlock += 1;
|
||||
}
|
||||
|
||||
if (bitsPerBlock > 8) {
|
||||
bitsPerBlock = GLOBAL_PALETTE;
|
||||
}
|
||||
|
||||
buffer.writeByte(bitsPerBlock);
|
||||
|
||||
// Write pallet (or not)
|
||||
if (bitsPerBlock != GLOBAL_PALETTE) {
|
||||
Type.VAR_INT.write(buffer, chunkSection.getPaletteSize());
|
||||
for (int i = 0; i < chunkSection.getPaletteSize(); i++) {
|
||||
Type.VAR_INT.write(buffer, chunkSection.getPaletteEntry(i));
|
||||
}
|
||||
}
|
||||
|
||||
long[] data = CompactArrayUtil.createCompactArrayWithPadding(bitsPerBlock, ChunkSection.SIZE,
|
||||
bitsPerBlock == GLOBAL_PALETTE ? chunkSection::getFlatBlock : chunkSection::getPaletteIndex);
|
||||
Type.VAR_INT.write(buffer, data.length);
|
||||
for (long l : data) {
|
||||
buffer.writeLong(l);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package us.myles.ViaVersion.api.type.types.version;
|
||||
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
public class Types1_16 {
|
||||
|
||||
/**
|
||||
* Chunk section type for 1.16
|
||||
*/
|
||||
public static final Type<ChunkSection> CHUNK_SECTION = new ChunkSectionType1_16();
|
||||
}
|
@ -131,7 +131,7 @@ public class MetadataRewriter1_14To1_13_2 extends MetadataRewriter {
|
||||
if (metadata.getId() >= 9) { // New piercing
|
||||
metadata.setId(metadata.getId() + 1);
|
||||
}
|
||||
} else if (type.is(Entity1_14Types.EntityType.FIREWORKS_ROCKET)) {
|
||||
} else if (type.is(Entity1_14Types.EntityType.FIREWORK_ROCKET)) {
|
||||
if (metadata.getId() == 8) {
|
||||
if (metadata.getValue().equals(0))
|
||||
metadata.setValue(null); // https://bugs.mojang.com/browse/MC-111480
|
||||
|
@ -77,7 +77,7 @@ public class EntityPackets {
|
||||
typeId = Entity1_14Types.EntityType.HOPPER_MINECART.getId();
|
||||
break;
|
||||
case 6:
|
||||
typeId = Entity1_14Types.EntityType.COMMANDBLOCK_MINECART.getId();
|
||||
typeId = Entity1_14Types.EntityType.COMMAND_BLOCK_MINECART.getId();
|
||||
break;
|
||||
}
|
||||
} else if ((type1_14.is(Entity1_14Types.EntityType.ITEM) && data > 0)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.metadata;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types;
|
||||
import us.myles.ViaVersion.api.entities.EntityType;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
@ -19,6 +20,8 @@ public class MetadataRewriter1_16To1_15_2 extends MetadataRewriter {
|
||||
|
||||
public MetadataRewriter1_16To1_15_2(Protocol1_16To1_15_2 protocol) {
|
||||
super(protocol, EntityTracker1_16.class);
|
||||
mapType(Entity1_15Types.EntityType.ZOMBIE_PIGMAN, Entity1_16Types.EntityType.ZOMBIFIED_PIGLIN);
|
||||
mapTypes(Entity1_15Types.EntityType.values(), Entity1_16Types.EntityType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,18 +53,4 @@ public class MetadataRewriter1_16To1_15_2 extends MetadataRewriter {
|
||||
protected EntityType getTypeFromId(int type) {
|
||||
return Entity1_16Types.getTypeFromId(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNewEntityId(final int oldId) {
|
||||
if (oldId == 57) {
|
||||
return 95;
|
||||
}
|
||||
if (oldId > 57 && oldId < 96) {
|
||||
return oldId - 1;
|
||||
}
|
||||
if (oldId > 102) {
|
||||
return oldId + 1;
|
||||
}
|
||||
return oldId;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import us.myles.ViaVersion.api.type.types.UUIDIntArrayType;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.Protocol1_16To1_15_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -41,7 +42,8 @@ public class WorldPackets {
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.passthrough(new Chunk1_15Type(clientWorld));
|
||||
Chunk chunk = wrapper.read(new Chunk1_15Type(clientWorld));
|
||||
wrapper.write(new Chunk1_16Type(clientWorld), chunk);
|
||||
for (int s = 0; s < 16; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.storage;
|
||||
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types.EntityType;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_16Types.EntityType;
|
||||
import us.myles.ViaVersion.api.storage.EntityTracker;
|
||||
|
||||
public class EntityTracker1_16 extends EntityTracker {
|
||||
|
@ -0,0 +1,108 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_16;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_16Type extends PartialType<Chunk, ClientWorld> {
|
||||
private static final CompoundTag[] A = new CompoundTag[0];
|
||||
|
||||
public Chunk1_16Type(ClientWorld param) {
|
||||
super(param, Chunk.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
||||
int chunkX = input.readInt();
|
||||
int chunkZ = input.readInt();
|
||||
|
||||
boolean fullChunk = input.readBoolean();
|
||||
int primaryBitmask = Type.VAR_INT.read(input);
|
||||
CompoundTag heightMap = Type.NBT.read(input);
|
||||
|
||||
int[] biomeData = fullChunk ? new int[1024] : null;
|
||||
if (fullChunk) {
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
biomeData[i] = input.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
Type.VAR_INT.read(input); // data size in bytes
|
||||
|
||||
// Read sections
|
||||
ChunkSection[] sections = new ChunkSection[16];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((primaryBitmask & (1 << i)) == 0) continue; // Section not set
|
||||
|
||||
short nonAirBlocksCount = input.readShort();
|
||||
ChunkSection section = Types1_16.CHUNK_SECTION.read(input);
|
||||
section.setNonAirBlocksCount(nonAirBlocksCount);
|
||||
sections[i] = section;
|
||||
}
|
||||
|
||||
List<CompoundTag> nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input)));
|
||||
|
||||
// Read all the remaining bytes (workaround for #681)
|
||||
if (input.readableBytes() > 0) {
|
||||
byte[] array = Type.REMAINING_BYTES.read(input);
|
||||
if (Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception {
|
||||
output.writeInt(chunk.getX());
|
||||
output.writeInt(chunk.getZ());
|
||||
|
||||
output.writeBoolean(chunk.isFullChunk());
|
||||
Type.VAR_INT.write(output, chunk.getBitmask());
|
||||
Type.NBT.write(output, chunk.getHeightMap());
|
||||
|
||||
// Write biome data
|
||||
if (chunk.isBiomeData()) {
|
||||
for (int value : chunk.getBiomeData()) {
|
||||
output.writeInt(value);
|
||||
}
|
||||
}
|
||||
|
||||
ByteBuf buf = output.alloc().buffer();
|
||||
try {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue; // Section not set
|
||||
|
||||
buf.writeShort(section.getNonAirBlocksCount());
|
||||
Types1_16.CHUNK_SECTION.write(buf, section);
|
||||
}
|
||||
buf.readerIndex(0);
|
||||
Type.VAR_INT.write(output, buf.readableBytes());
|
||||
output.writeBytes(buf);
|
||||
} finally {
|
||||
buf.release(); // release buffer
|
||||
}
|
||||
|
||||
// Write Block Entities
|
||||
Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(A));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Type> getBaseClass() {
|
||||
return BaseChunkType.class;
|
||||
}
|
||||
}
|
@ -3,18 +3,77 @@ package us.myles.ViaVersion.util;
|
||||
import java.util.function.IntToLongFunction;
|
||||
|
||||
public class CompactArrayUtil {
|
||||
//Oh no
|
||||
private static final int[] MAGIC = new int[] {
|
||||
-1, -1, 0, Integer.MIN_VALUE, 0, 0, 1431655765, 1431655765, 0, Integer.MIN_VALUE,
|
||||
0, 1, 858993459, 858993459, 0, 715827882, 715827882, 0, 613566756, 613566756,
|
||||
0, Integer.MIN_VALUE, 0, 2, 477218588, 477218588, 0, 429496729, 429496729, 0,
|
||||
390451572, 390451572, 0, 357913941, 357913941, 0, 330382099, 330382099, 0, 306783378,
|
||||
306783378, 0, 286331153, 286331153, 0, Integer.MIN_VALUE, 0, 3, 252645135, 252645135,
|
||||
0, 238609294, 238609294, 0, 226050910, 226050910, 0, 214748364, 214748364, 0,
|
||||
204522252, 204522252, 0, 195225786, 195225786, 0, 186737708, 186737708, 0, 178956970,
|
||||
178956970, 0, 171798691, 171798691, 0, 165191049, 165191049, 0, 159072862, 159072862,
|
||||
0, 153391689, 153391689, 0, 148102320, 148102320, 0, 143165576, 143165576, 0,
|
||||
138547332, 138547332, 0, Integer.MIN_VALUE, 0, 4, 130150524, 130150524, 0, 126322567,
|
||||
126322567, 0, 122713351, 122713351, 0, 119304647, 119304647, 0, 116080197, 116080197,
|
||||
0, 113025455, 113025455, 0, 110127366, 110127366, 0, 107374182, 107374182, 0,
|
||||
104755299, 104755299, 0, 102261126, 102261126, 0, 99882960, 99882960, 0, 97612893,
|
||||
97612893, 0, 95443717, 95443717, 0, 93368854, 93368854, 0, 91382282, 91382282,
|
||||
0, 89478485, 89478485, 0, 87652393, 87652393, 0, 85899345, 85899345, 0,
|
||||
84215045, 84215045, 0, 82595524, 82595524, 0, 81037118, 81037118, 0, 79536431,
|
||||
79536431, 0, 78090314, 78090314, 0, 76695844, 76695844, 0, 75350303, 75350303,
|
||||
0, 74051160, 74051160, 0, 72796055, 72796055, 0, 71582788, 71582788, 0,
|
||||
70409299, 70409299, 0, 69273666, 69273666, 0, 68174084, 68174084, 0, Integer.MIN_VALUE,
|
||||
0, 5 };
|
||||
|
||||
private CompactArrayUtil() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static long[] createCompactArrayWithPadding(int bitsPerEntry, int entries, IntToLongFunction valueGetter) {
|
||||
long maxEntryValue = (1L << bitsPerEntry) - 1;
|
||||
char valuesPerLong = (char) (64 / bitsPerEntry);
|
||||
int magicIndex = 3 * (valuesPerLong - 1);
|
||||
long divideMul = Integer.toUnsignedLong(MAGIC[magicIndex]);
|
||||
long divideAdd = Integer.toUnsignedLong(MAGIC[magicIndex + 1]);
|
||||
int divideShift = MAGIC[magicIndex + 2];
|
||||
int size = (4096 + valuesPerLong - 1) / valuesPerLong;
|
||||
|
||||
long[] data = new long[size];
|
||||
|
||||
for (int i = 0; i < entries; i++) {
|
||||
long value = valueGetter.applyAsLong(i);
|
||||
int cellIndex = (int) (i * divideMul + divideAdd >> 32L >> divideShift);
|
||||
int bitIndex = (i - cellIndex * valuesPerLong) * bitsPerEntry;
|
||||
data[cellIndex] = data[cellIndex] & ~(maxEntryValue << bitIndex) | (value & maxEntryValue) << bitIndex;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
public static void iterateCompactArrayWithPadding(int bitsPerEntry, int entries, long[] data, BiIntConsumer consumer) {
|
||||
long maxEntryValue = (1L << bitsPerEntry) - 1;
|
||||
char valuesPerLong = (char) (64 / bitsPerEntry);
|
||||
int magicIndex = 3 * (valuesPerLong - 1);
|
||||
long divideMul = Integer.toUnsignedLong(MAGIC[magicIndex]);
|
||||
long divideAdd = Integer.toUnsignedLong(MAGIC[magicIndex + 1]);
|
||||
int divideShift = MAGIC[magicIndex + 2];
|
||||
|
||||
for (int i = 0; i < entries; i++) {
|
||||
int cellIndex = (int) (i * divideMul + divideAdd >> 32L >> divideShift);
|
||||
int bitIndex = (i - cellIndex * valuesPerLong) * bitsPerEntry;
|
||||
int value = (int) (data[cellIndex] >> bitIndex & maxEntryValue);
|
||||
consumer.consume(i, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static long[] createCompactArray(int bitsPerEntry, int entries, IntToLongFunction valueGetter) {
|
||||
long maxEntryValue = (1L << bitsPerEntry) - 1;
|
||||
long[] data = new long[(int) Math.ceil(entries * bitsPerEntry / 64.0)];
|
||||
for (int index = 0; index < entries; index++) {
|
||||
long value = valueGetter.applyAsLong(index);
|
||||
int bitIndex = index * bitsPerEntry;
|
||||
for (int i = 0; i < entries; i++) {
|
||||
long value = valueGetter.applyAsLong(i);
|
||||
int bitIndex = i * bitsPerEntry;
|
||||
int startIndex = bitIndex / 64;
|
||||
int endIndex = ((index + 1) * bitsPerEntry - 1) / 64;
|
||||
int endIndex = ((i + 1) * bitsPerEntry - 1) / 64;
|
||||
int startBitSubIndex = bitIndex % 64;
|
||||
data[startIndex] = data[startIndex] & ~(maxEntryValue << startBitSubIndex) | (value & maxEntryValue) << startBitSubIndex;
|
||||
if (startIndex != endIndex) {
|
||||
@ -32,14 +91,14 @@ public class CompactArrayUtil {
|
||||
int startIndex = bitIndex / 64;
|
||||
int endIndex = ((i + 1) * bitsPerEntry - 1) / 64;
|
||||
int startBitSubIndex = bitIndex % 64;
|
||||
int val;
|
||||
int value;
|
||||
if (startIndex == endIndex) {
|
||||
val = (int) (data[startIndex] >>> startBitSubIndex & maxEntryValue);
|
||||
value = (int) (data[startIndex] >>> startBitSubIndex & maxEntryValue);
|
||||
} else {
|
||||
int endBitSubIndex = 64 - startBitSubIndex;
|
||||
val = (int) ((data[startIndex] >>> startBitSubIndex | data[endIndex] << endBitSubIndex) & maxEntryValue);
|
||||
value = (int) ((data[startIndex] >>> startBitSubIndex | data[endIndex] << endBitSubIndex) & maxEntryValue);
|
||||
}
|
||||
consumer.consume(i, val);
|
||||
consumer.consume(i, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren