entity refactoring and mapping (1.13)

This commit is contained in:
Bixilon 2020-07-10 15:25:30 +02:00
parent f52c049729
commit 4f7e64112b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
11 changed files with 200 additions and 111 deletions

View File

@ -13,109 +13,127 @@
package de.bixilon.minosoft.game.datatypes.entities;
import de.bixilon.minosoft.game.datatypes.MapSet;
import de.bixilon.minosoft.game.datatypes.VersionValueMap;
import de.bixilon.minosoft.game.datatypes.entities.mob.*;
import de.bixilon.minosoft.game.datatypes.entities.objects.*;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public enum Entities {
ITEM(1, ItemStack.class),
XP_ORB(2, ExperienceOrb.class),
AREA_EFFECT_CLOUD(3, AreaEffectCloud.class),
ELDER_GUARDIAN(4, ElderGuardian.class),
WITHER_SKELETON(5, WitherSkeleton.class),
STRAY_SKELETON(6, StraySkeleton.class),
THROWN_EGG(7, ThrownEgg.class),
LEASH_KNOT(8, LeashKnot.class),
PAINTING(9, Painting.class),
ARROW(10, Arrow.class),
SNOWBALL(11, Snowball.class),
FIRE_BALL(12, FireBall.class),
SMALL_FIRE_BALL(13, SmallFireBall.class),
THROWN_ENDERPEARL(14, ThrownEnderpearl.class),
EYE_OF_ENDER_SIGNAL(15, EyeOfEnder.class),
THROWN_POTION(16, ThrownPotion.class),
THROWN_EXP_BOTTLE(17, ThrownExpBottle.class),
ITEM_FRAME(18, ItemFrame.class),
WITHER_SKULL(19, WitherSkull.class),
PRIMED_TNT(20, PrimedTNT.class),
FALLING_BLOCK(21, FallingBlock.class),
FIREWORK(22, Firework.class),
HUSK(23, Husk.class),
SPECTRAL_ARROW(24, SpectralArrow.class),
SHULKER_BULLET(25, ShulkerBullet.class),
DRAGON_FIRE_BALL(26, DragonFireball.class),
ZOMBIE_VILLAGER(27, ZombieVillager.class),
SKELETON_HORSE(28, SkeletonHorse.class),
ZOMBIE_HORSE(29, ZombieHorse.class),
ARMOR_STAND(30, ArmorStand.class),
DONKEY(31, Donkey.class),
MULE(32, Mule.class),
EVOCATION_FANGS(33, EvocationFangs.class),
EVOCATION_ILLAGER(34, Evoker.class),
VEX(35, Vex.class),
VINDICATION_ILLAGER(36, Vindicator.class),
ILLUSIONER(37, Illusioner.class),
MINECART_COMMAND_BLOCK(40, MinecartCommandBlock.class),
BOAT(41, Boat.class),
MINECART_RIDE_ABLE(42, Minecart.class),
MINECART_CHEST(43, Minecart.class),
CREEPER(50, Creeper.class),
SKELETON(51, Skeleton.class),
SPIDER(52, Spider.class),
GIANT_ZOMBIE(53, GiantZombie.class),
ZOMBIE(54, Zombie.class),
SLIME(55, Slime.class),
GHAST(56, Ghast.class),
ZOMBIE_PIGMAN(57, ZombiePigman.class),
ENDERMAN(58, EnderMan.class),
CAVE_SPIDER(59, CaveSpider.class),
SILVERFISH(60, Silverfish.class),
BLAZE(61, Blaze.class),
MAGMA_CUBE(62, MagmaCube.class),
ENDER_DRAGON(63, EnderDragon.class),
WITHER(64, Wither.class),
BAT(65, Bat.class),
WITCH(66, Witch.class),
GUARDIAN(68, Guardian.class),
SHULKER(69, Shulker.class),
PIG(90, Pig.class),
SHEEP(91, Sheep.class),
COW(92, Cow.class),
CHICKEN(93, Chicken.class),
SQUID(94, Squid.class),
WOLF(95, Wolf.class),
MOOSHROOM(96, Mooshroom.class),
SNOW_GOLEM(97, SnowGolem.class),
OCELOT(98, Ocelot.class),
IRON_GOLEM(99, IronGolem.class),
HORSE(100, Horse.class),
RABBIT(101, Rabbit.class),
POLAR_BEAR(102, PolarBear.class),
LLAMA(103, Llama.class),
LLAMA_SPIT(104, LlamaSpit.class),
PLAYER(-1, OtherPlayer.class),
PARROT(105, Parrot.class),
VILLAGER(120, Villager.class),
ENDER_CRYSTAL(200, EnderCrystal.class),
ITEM(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 1), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 32)}, ItemStack.class),
XP_ORB(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 2), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 22)}, ExperienceOrb.class),
AREA_EFFECT_CLOUD(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_8, 3), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 0)}, AreaEffectCloud.class),
ELDER_GUARDIAN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_8, 4), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 15)}, ElderGuardian.class),
WITHER_SKELETON(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 5), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 84)}, WitherSkeleton.class),
STRAY_SKELETON(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 6), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 71)}, StraySkeleton.class),
THROWN_EGG(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 7), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 74)}, ThrownEgg.class),
LEASH_KNOT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 8), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 35)}, LeashKnot.class),
PAINTING(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 9), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 49)}, Painting.class),
ARROW(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 10), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 2)}, Arrow.class),
SNOWBALL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 11), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 67)}, Snowball.class),
FIREBALL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 12), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 34)}, Fireball.class),
SMALL_FIREBALL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 13), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 65)}, SmallFireball.class),
THROWN_ENDERPEARL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 14), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 75)}, ThrownEnderpearl.class),
EYE_OF_ENDER_SIGNAL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 15), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 23)}, EyeOfEnder.class),
THROWN_POTION(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 16), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 77)}, ThrownPotion.class),
THROWN_EXP_BOTTLE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 17), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 76)}, ThrownExpBottle.class),
ITEM_FRAME(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 18), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 33)}, ItemFrame.class),
WITHER_SKULL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 19), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 85)}, WitherSkull.class),
PRIMED_TNT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 20), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 55)}, PrimedTNT.class),
FALLING_BLOCK(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 21), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 24)}, FallingBlock.class),
FIREWORK(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 22), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 25)}, Firework.class),
HUSK(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 23), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 30)}, Husk.class),
SPECTRAL_ARROW(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 24), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 68)}, SpectralArrow.class),
SHULKER_BULLET(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 25), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 60)}, ShulkerBullet.class),
DRAGON_FIREBALL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 26), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 13)}, DragonFireball.class),
ZOMBIE_VILLAGER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 27), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 89)}, ZombieVillager.class),
SKELETON_HORSE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 28), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 63)}, SkeletonHorse.class),
ZOMBIE_HORSE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 29), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 88)}, ZombieHorse.class),
ARMOR_STAND(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_8, 30), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 1)}, ArmorStand.class),
DONKEY(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 31), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 11)}, Donkey.class),
MULE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 32), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 46)}, Mule.class),
EVOCATION_FANGS(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 33), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 20)}, EvocationFangs.class),
EVOKER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 34), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 21)}, Evoker.class),
VEX(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 35), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 78)}, Vex.class),
VINDICATOR(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 36), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 81)}, Vindicator.class),
ILLUSIONER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 37), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 31)}, Illusioner.class),
MINECART_COMMAND_BLOCK(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 40), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 41)}, MinecartCommandBlock.class),
BOAT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 41), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 5)}, Boat.class),
MINECART_RIDE_ABLE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 42), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 39)}, Minecart.class),
MINECART_CHEST(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 43), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 40)}, Minecart.class),
CREEPER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 50), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 10)}, Creeper.class),
SKELETON(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 51), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 62)}, Skeleton.class),
SPIDER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 52), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 69)}, Spider.class),
GIANT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 53), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 27)}, GiantZombie.class),
ZOMBIE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 54), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 87)}, Zombie.class),
SLIME(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 55), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 64)}, Slime.class),
GHAST(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 56), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 26)}, Ghast.class),
ZOMBIE_PIGMAN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 57), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 53)}, ZombiePigman.class),
ENDERMAN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 58), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 18)}, Enderman.class),
CAVE_SPIDER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 9), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 6)}, CaveSpider.class),
SILVERFISH(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 60), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 61)}, Silverfish.class),
BLAZE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 61), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 4)}, Blaze.class),
MAGMA_CUBE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 62), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 38)}, MagmaCube.class),
ENDER_DRAGON(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 63), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 17)}, EnderDragon.class),
WITHER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 64), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 83)}, Wither.class),
BAT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 65), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 3)}, Bat.class),
WITCH(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 66), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 82)}, Witch.class),
GUARDIAN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_8, 68), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 28)}, Guardian.class),
SHULKER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 69), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 59)}, Shulker.class),
PIG(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 90), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 51)}, Pig.class),
SHEEP(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 91), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 58)}, Sheep.class),
COW(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 92), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 9)}, Cow.class),
CHICKEN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 93), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 7)}, Chicken.class),
SQUID(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 94), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 70)}, Squid.class),
WOLF(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 95), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 86)}, Wolf.class),
MOOSHROOM(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 96), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 47)}, Mooshroom.class),
SNOW_GOLEM(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 97), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 66)}, SnowGolem.class),
OCELOT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 98), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 48)}, Ocelot.class),
IRON_GOLEM(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 99), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 80)}, IronGolem.class),
HORSE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 100), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 29)}, Horse.class),
RABBIT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_8, 101), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 56)}, Rabbit.class),
POLAR_BEAR(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 102), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 54)}, PolarBear.class),
LLAMA(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 103), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 36)}, Llama.class),
LLAMA_SPIT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_10, 104), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 37)}, LlamaSpit.class),
PLAYER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, -1), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 92)}, OtherPlayer.class),
PARROT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_12_2, 105), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 50)}, Parrot.class),
VILLAGER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 120), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 79)}, Villager.class),
ENDER_CRYSTAL(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 200), new MapSet<>(ProtocolVersion.VERSION_1_13_2, 16)}, EnderCrystal.class),
COD(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 8)}, Cod.class),
DOLPHIN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 12)}, Dolphin.class),
DROWNED(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 14)}, Drowned.class),
ENDERMITE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 19)}, Endermite.class),
MINECART_FURNACE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 42)}, MinecartFurnace.class),
MINECART_HOPPER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 43)}, MinecartHopper.class),
MINECART_SPAWNER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 44)}, MinecarSpawner.class),
MINECART_TNT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 45)}, MinecartTNT.class),
PUFFERFISH(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 52)}, Pufferfish.class),
SALMON(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 57)}, Salmon.class),
TROPICAL_FISH(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 72)}, TropicalFish.class),
TURTLE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 73)}, Turtle.class),
PHANTOM(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 90)}, Phantom.class),
LIGHTNING_BOLT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 91)}, LightningBolt.class),
FISHING_BOBBER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 93)}, FishingBobber.class),
TRIDENT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_13_2, 94)}, Trident.class),
// not a thing anymore
FALLING_DRAGON_EGG(-1, FallingDragonEgg.class),
FIRE_CHARGE(-1, FireCharge.class),
FISHING_FLOAT(-1, FishingFloat.class),
;
FALLING_DRAGON_EGG(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, -1)}, FallingDragonEgg.class),
FIRE_CHARGE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, -1)}, FireCharge.class),
FISHING_FLOAT(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, -1)}, FishingFloat.class);
final int type;
final VersionValueMap<Integer> valueMap;
final Class<? extends Entity> clazz;
Entities(int type, Class<? extends Entity> clazz) {
this.type = type;
Entities(MapSet<ProtocolVersion, Integer>[] values, Class<? extends Entity> clazz) {
valueMap = new VersionValueMap<>(values, true);
this.clazz = clazz;
}
public static Entities byType(int type) {
for (Entities b : values()) {
if (b.getType() == type) {
return b;
public static Entities byId(int id, ProtocolVersion version) {
for (Entities entity : values()) {
if (entity.getType() == id) {
return entity;
}
}
return null;

View File

@ -25,7 +25,7 @@ public enum Objects implements EntityEnumInterface {
ARROW(60, Arrow.class), // ToDo: Tipped Arrows
SNOWBALL(61, Snowball.class),
EGG(62, ThrownEgg.class),
FIRE_BALL(63, FireBall.class),
FIREBALL(63, Fireball.class),
FIRE_CHARGE(64, FireCharge.class),
ENDER_PEARL(65, ThrownEnderpearl.class),
WITHER_SKULL(66, WitherSkull.class),
@ -43,7 +43,8 @@ public enum Objects implements EntityEnumInterface {
EVOCATION_FANGS(78, EvocationFangs.class),
FISHING_FLOAT(90, FishingFloat.class),
SPECTRAL_ARROW(91, SpectralArrow.class),
DRAGON_FIREBALL(93, DragonFireball.class);
DRAGON_FIREBALL(93, DragonFireball.class),
TRIDENT(94, Trident.class);
//ToDO: size changed between versions, fix it!

View File

@ -20,10 +20,10 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class EnderMan extends Mob implements MobInterface {
public class Enderman extends Mob implements MobInterface {
EndermanMetaData metaData;
public EnderMan(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
public Enderman(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new EndermanMetaData(sets, version);
}

View File

@ -31,7 +31,7 @@ public class Evoker extends Mob implements MobInterface {
@Override
public Entities getEntityType() {
return Entities.EVOCATION_ILLAGER;
return Entities.EVOKER;
}
@Override

View File

@ -28,7 +28,7 @@ public class GiantZombie extends Zombie {
@Override
public Entities getEntityType() {
return Entities.GIANT_ZOMBIE;
return Entities.GIANT;
}
@Override

View File

@ -31,7 +31,7 @@ public class Vindicator extends Mob implements MobInterface {
@Override
public Entities getEntityType() {
return Entities.VINDICATION_ILLAGER;
return Entities.VINDICATOR;
}
@Override

View File

@ -43,7 +43,7 @@ public class DragonFireball extends EntityObject implements ObjectInterface {
@Override
public Entities getEntityType() {
return Entities.DRAGON_FIRE_BALL;
return Entities.DRAGON_FIREBALL;
}
@Override

View File

@ -19,22 +19,22 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class FireBall extends EntityObject implements ObjectInterface {
public class Fireball extends EntityObject implements ObjectInterface {
final int thrower;
EntityMetaData metaData;
public FireBall(int entityId, Location location, short yaw, short pitch, int additionalInt) {
public Fireball(int entityId, Location location, short yaw, short pitch, int additionalInt) {
super(entityId, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
this.thrower = additionalInt;
}
public FireBall(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
public Fireball(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(entityId, location, yaw, pitch, velocity);
this.thrower = additionalInt;
}
public FireBall(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
public Fireball(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new EntityMetaData(sets, version);
this.thrower = 0; //ToDo
@ -42,7 +42,7 @@ public class FireBall extends EntityObject implements ObjectInterface {
@Override
public Entities getEntityType() {
return Entities.FIRE_BALL;
return Entities.FIREBALL;
}
@Override

View File

@ -19,22 +19,22 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class SmallFireBall extends EntityObject implements ObjectInterface {
public class SmallFireball extends EntityObject implements ObjectInterface {
final int thrower;
EntityMetaData metaData;
public SmallFireBall(int entityId, Location location, short yaw, short pitch, int additionalInt) {
public SmallFireball(int entityId, Location location, short yaw, short pitch, int additionalInt) {
super(entityId, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
this.thrower = additionalInt;
}
public SmallFireBall(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
public SmallFireball(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(entityId, location, yaw, pitch, velocity);
this.thrower = additionalInt;
}
public SmallFireBall(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
public SmallFireball(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new EntityMetaData(sets, version);
this.thrower = 0; //ToDo
@ -42,7 +42,7 @@ public class SmallFireBall extends EntityObject implements ObjectInterface {
@Override
public Entities getEntityType() {
return Entities.SMALL_FIRE_BALL;
return Entities.SMALL_FIREBALL;
}
@Override

View File

@ -0,0 +1,70 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.game.datatypes.entities.objects;
import de.bixilon.minosoft.game.datatypes.entities.*;
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.TridentMetaData;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import java.util.HashMap;
public class Trident extends EntityObject implements ObjectInterface {
TridentMetaData metaData;
public Trident(int entityId, Location location, short yaw, short pitch, int additionalInt) {
super(entityId, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int
}
public Trident(int entityId, Location location, short yaw, short pitch, int additionalInt, Velocity velocity) {
super(entityId, location, yaw, pitch, velocity);
}
public Trident(int entityId, Location location, short yaw, short pitch, Velocity velocity, HashMap<Integer, EntityMetaData.MetaDataSet> sets, ProtocolVersion version) {
super(entityId, location, yaw, pitch, velocity);
this.metaData = new TridentMetaData(sets, version);
}
@Override
public Entities getEntityType() {
return Entities.TRIDENT;
}
@Override
public TridentMetaData getMetaData() {
return metaData;
}
@Override
public void setMetaData(EntityMetaData metaData) {
this.metaData = (TridentMetaData) metaData;
}
@Override
public float getWidth() {
return 0.25F;
}
@Override
public float getHeight() {
return 0.25F;
}
@Override
public Class<? extends EntityMetaData> getMetaDataClass() {
return TridentMetaData.class;
}
}

View File

@ -37,7 +37,7 @@ public class PacketSpawnMob implements ClientboundPacket {
case VERSION_1_7_10:
case VERSION_1_8: {
int entityId = buffer.readVarInt();
Entities type = Entities.byType(buffer.readByte());
Entities type = Entities.byId(buffer.readByte());
Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
short yaw = buffer.readAngle();
short pitch = buffer.readAngle();
@ -58,7 +58,7 @@ public class PacketSpawnMob implements ClientboundPacket {
case VERSION_1_10: {
int entityId = buffer.readVarInt();
UUID uuid = buffer.readUUID();
Entities type = Entities.byType(buffer.readByte());
Entities type = Entities.byId(buffer.readByte());
Location location = new Location(buffer.readDouble(), buffer.readDouble(), buffer.readDouble());
short yaw = buffer.readAngle();
short pitch = buffer.readAngle();
@ -79,7 +79,7 @@ public class PacketSpawnMob implements ClientboundPacket {
case VERSION_1_13_2: {
int entityId = buffer.readVarInt();
UUID uuid = buffer.readUUID();
Entities type = Entities.byType(buffer.readVarInt());
Entities type = Entities.byId(buffer.readVarInt());
Location location = new Location(buffer.readDouble(), buffer.readDouble(), buffer.readDouble());
short yaw = buffer.readAngle();
short pitch = buffer.readAngle();