3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-03 08:21:06 +02:00

1.18 entity name and metadata changes (#2651)

* Fix amount & javaId being used before it is initialized

Fixes invisible falling blocks and incorrectly sized exp orbs

* Add missing item metadata to throwable items and fireballs

Renamed ItemedFireballEntity -> FireballEntity

* Renamed more EntityDefinitions to match MCProtocolLib

* Add some missing metadata and add null check

* Use entity type when possible in debug spawn message

Fallback onto classes simple name
Also don't register ENDER_DRAGON_PART

* Remove redundant entity identifiers and fix END_CRYSTAL and FISHING_BOBBER identifiers

minecraft:end_crystal -> minecraft:ender_crystal
minecraft:fishing_book -> minecraft:fishing_hook

* Cave spider should inherit metadata from spider

* Keep entity definitions in roughly alphabetical order

* Alphabetize entity definitions

* ABCs?

* Bump MCProtocolLib version
Dieser Commit ist enthalten in:
David Choo 2021-11-26 23:03:46 -05:00 committet von GitHub
Ursprung 0d7bf7b71a
Commit a305c22665
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
14 geänderte Dateien mit 135 neuen und 127 gelöschten Zeilen

Datei anzeigen

@ -155,7 +155,7 @@
<dependency> <dependency>
<groupId>com.github.GeyserMC</groupId> <groupId>com.github.GeyserMC</groupId>
<artifactId>MCProtocolLib</artifactId> <artifactId>MCProtocolLib</artifactId>
<version>7f7808e2</version> <version>f7f84e7</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>

Datei anzeigen

@ -63,36 +63,43 @@ public final class EntityDefinitions {
public static final EntityDefinition<BlazeEntity> BLAZE; public static final EntityDefinition<BlazeEntity> BLAZE;
public static final EntityDefinition<BoatEntity> BOAT; public static final EntityDefinition<BoatEntity> BOAT;
public static final EntityDefinition<CatEntity> CAT; public static final EntityDefinition<CatEntity> CAT;
public static final EntityDefinition<MonsterEntity> CAVE_SPIDER; public static final EntityDefinition<SpiderEntity> CAVE_SPIDER;
public static final EntityDefinition<MinecartEntity> CHEST_MINECART;
public static final EntityDefinition<ChickenEntity> CHICKEN; public static final EntityDefinition<ChickenEntity> CHICKEN;
public static final EntityDefinition<CreeperEntity> CREEPER;
public static final EntityDefinition<AbstractFishEntity> COD; public static final EntityDefinition<AbstractFishEntity> COD;
public static final EntityDefinition<CommandBlockMinecartEntity> COMMAND_BLOCK_MINECART;
public static final EntityDefinition<AnimalEntity> COW; public static final EntityDefinition<AnimalEntity> COW;
public static final EntityDefinition<ChestedHorseEntity> DONKEY; public static final EntityDefinition<CreeperEntity> CREEPER;
public static final EntityDefinition<WaterEntity> DOLPHIN; public static final EntityDefinition<WaterEntity> DOLPHIN;
public static final EntityDefinition<ItemedFireballEntity> DRAGON_FIREBALL; public static final EntityDefinition<ChestedHorseEntity> DONKEY;
public static final EntityDefinition<FireballEntity> DRAGON_FIREBALL;
public static final EntityDefinition<ZombieEntity> DROWNED; public static final EntityDefinition<ZombieEntity> DROWNED;
public static final EntityDefinition<ThrowableItemEntity> EGG;
public static final EntityDefinition<ElderGuardianEntity> ELDER_GUARDIAN; public static final EntityDefinition<ElderGuardianEntity> ELDER_GUARDIAN;
public static final EntityDefinition<EndermanEntity> ENDERMAN; public static final EntityDefinition<EndermanEntity> ENDERMAN;
public static final EntityDefinition<MonsterEntity> ENDERMITE; public static final EntityDefinition<MonsterEntity> ENDERMITE;
public static final EntityDefinition<EnderDragonEntity> ENDER_DRAGON; public static final EntityDefinition<EnderDragonEntity> ENDER_DRAGON;
public static final EntityDefinition<ThrowableItemEntity> ENDER_PEARL;
public static final EntityDefinition<EnderCrystalEntity> END_CRYSTAL; public static final EntityDefinition<EnderCrystalEntity> END_CRYSTAL;
public static final EntityDefinition<SpellcasterIllagerEntity> EVOKER; public static final EntityDefinition<SpellcasterIllagerEntity> EVOKER;
public static final EntityDefinition<Entity> EVOKER_FANGS; public static final EntityDefinition<Entity> EVOKER_FANGS;
public static final EntityDefinition<ThrowableItemEntity> EXPERIENCE_BOTTLE;
public static final EntityDefinition<ExpOrbEntity> EXPERIENCE_ORB; public static final EntityDefinition<ExpOrbEntity> EXPERIENCE_ORB;
public static final EntityDefinition<Entity> EYE_OF_ENDER; public static final EntityDefinition<Entity> EYE_OF_ENDER;
public static final EntityDefinition<FallingBlockEntity> FALLING_BLOCK; public static final EntityDefinition<FallingBlockEntity> FALLING_BLOCK;
public static final EntityDefinition<ItemedFireballEntity> FIREBALL; public static final EntityDefinition<FireballEntity> FIREBALL;
public static final EntityDefinition<FishingHookEntity> FISHING_BOBBER;
public static final EntityDefinition<FireworkEntity> FIREWORK_ROCKET; public static final EntityDefinition<FireworkEntity> FIREWORK_ROCKET;
public static final EntityDefinition<FishingHookEntity> FISHING_BOBBER;
public static final EntityDefinition<FoxEntity> FOX; public static final EntityDefinition<FoxEntity> FOX;
public static final EntityDefinition<GiantEntity> GIANT; public static final EntityDefinition<FurnaceMinecartEntity> FURNACE_MINECART; // Not present on Bedrock
public static final EntityDefinition<GhastEntity> GHAST; public static final EntityDefinition<GhastEntity> GHAST;
public static final EntityDefinition<GiantEntity> GIANT;
public static final EntityDefinition<ItemFrameEntity> GLOW_ITEM_FRAME; public static final EntityDefinition<ItemFrameEntity> GLOW_ITEM_FRAME;
public static final EntityDefinition<GlowSquidEntity> GLOW_SQUID; public static final EntityDefinition<GlowSquidEntity> GLOW_SQUID;
public static final EntityDefinition<GoatEntity> GOAT; public static final EntityDefinition<GoatEntity> GOAT;
public static final EntityDefinition<GuardianEntity> GUARDIAN; public static final EntityDefinition<GuardianEntity> GUARDIAN;
public static final EntityDefinition<HoglinEntity> HOGLIN; public static final EntityDefinition<HoglinEntity> HOGLIN;
public static final EntityDefinition<MinecartEntity> HOPPER_MINECART;
public static final EntityDefinition<HorseEntity> HORSE; public static final EntityDefinition<HorseEntity> HORSE;
public static final EntityDefinition<ZombieEntity> HUSK; public static final EntityDefinition<ZombieEntity> HUSK;
public static final EntityDefinition<SpellcasterIllagerEntity> ILLUSIONER; // Not present on Bedrock public static final EntityDefinition<SpellcasterIllagerEntity> ILLUSIONER; // Not present on Bedrock
@ -105,12 +112,6 @@ public final class EntityDefinitions {
public static final EntityDefinition<ThrowableEntity> LLAMA_SPIT; public static final EntityDefinition<ThrowableEntity> LLAMA_SPIT;
public static final EntityDefinition<MagmaCubeEntity> MAGMA_CUBE; public static final EntityDefinition<MagmaCubeEntity> MAGMA_CUBE;
public static final EntityDefinition<MinecartEntity> MINECART; public static final EntityDefinition<MinecartEntity> MINECART;
public static final EntityDefinition<MinecartEntity> MINECART_CHEST;
public static final EntityDefinition<CommandBlockMinecartEntity> MINECART_COMMAND_BLOCK;
public static final EntityDefinition<MinecartEntity> MINECART_HOPPER;
public static final EntityDefinition<FurnaceMinecartEntity> MINECART_FURNACE; // Not present on Bedrock
public static final EntityDefinition<SpawnerMinecartEntity> MINECART_SPAWNER; // Not present on Bedrock
public static final EntityDefinition<MinecartEntity> MINECART_TNT;
public static final EntityDefinition<MooshroomEntity> MOOSHROOM; public static final EntityDefinition<MooshroomEntity> MOOSHROOM;
public static final EntityDefinition<ChestedHorseEntity> MULE; public static final EntityDefinition<ChestedHorseEntity> MULE;
public static final EntityDefinition<OcelotEntity> OCELOT; public static final EntityDefinition<OcelotEntity> OCELOT;
@ -124,7 +125,7 @@ public final class EntityDefinitions {
public static final EntityDefinition<PillagerEntity> PILLAGER; public static final EntityDefinition<PillagerEntity> PILLAGER;
public static final EntityDefinition<PlayerEntity> PLAYER; public static final EntityDefinition<PlayerEntity> PLAYER;
public static final EntityDefinition<PolarBearEntity> POLAR_BEAR; public static final EntityDefinition<PolarBearEntity> POLAR_BEAR;
public static final EntityDefinition<TNTEntity> PRIMED_TNT; public static final EntityDefinition<ThrownPotionEntity> POTION;
public static final EntityDefinition<PufferFishEntity> PUFFERFISH; public static final EntityDefinition<PufferFishEntity> PUFFERFISH;
public static final EntityDefinition<RabbitEntity> RABBIT; public static final EntityDefinition<RabbitEntity> RABBIT;
public static final EntityDefinition<RaidParticipantEntity> RAVAGER; public static final EntityDefinition<RaidParticipantEntity> RAVAGER;
@ -136,31 +137,30 @@ public final class EntityDefinitions {
public static final EntityDefinition<SkeletonEntity> SKELETON; public static final EntityDefinition<SkeletonEntity> SKELETON;
public static final EntityDefinition<AbstractHorseEntity> SKELETON_HORSE; public static final EntityDefinition<AbstractHorseEntity> SKELETON_HORSE;
public static final EntityDefinition<SlimeEntity> SLIME; public static final EntityDefinition<SlimeEntity> SLIME;
public static final EntityDefinition<ItemedFireballEntity> SMALL_FIREBALL; public static final EntityDefinition<FireballEntity> SMALL_FIREBALL;
public static final EntityDefinition<ThrowableItemEntity> SNOWBALL; public static final EntityDefinition<ThrowableItemEntity> SNOWBALL;
public static final EntityDefinition<SnowGolemEntity> SNOW_GOLEM; public static final EntityDefinition<SnowGolemEntity> SNOW_GOLEM;
public static final EntityDefinition<SpawnerMinecartEntity> SPAWNER_MINECART; // Not present on Bedrock
public static final EntityDefinition<AbstractArrowEntity> SPECTRAL_ARROW; public static final EntityDefinition<AbstractArrowEntity> SPECTRAL_ARROW;
public static final EntityDefinition<SpiderEntity> SPIDER; public static final EntityDefinition<SpiderEntity> SPIDER;
public static final EntityDefinition<SquidEntity> SQUID; public static final EntityDefinition<SquidEntity> SQUID;
public static final EntityDefinition<AbstractSkeletonEntity> STRAY; public static final EntityDefinition<AbstractSkeletonEntity> STRAY;
public static final EntityDefinition<StriderEntity> STRIDER; public static final EntityDefinition<StriderEntity> STRIDER;
public static final EntityDefinition<ThrowableItemEntity> THROWN_EGG; public static final EntityDefinition<TNTEntity> TNT;
public static final EntityDefinition<ThrowableItemEntity> THROWN_ENDERPEARL; public static final EntityDefinition<MinecartEntity> TNT_MINECART;
public static final EntityDefinition<ThrowableItemEntity> THROWN_EXP_BOTTLE;
public static final EntityDefinition<ThrownPotionEntity> THROWN_POTION;
public static final EntityDefinition<TropicalFishEntity> TROPICAL_FISH;
public static final EntityDefinition<TurtleEntity> TURTLE;
public static final EntityDefinition<TraderLlamaEntity> TRADER_LLAMA; public static final EntityDefinition<TraderLlamaEntity> TRADER_LLAMA;
public static final EntityDefinition<TridentEntity> TRIDENT; public static final EntityDefinition<TridentEntity> TRIDENT;
public static final EntityDefinition<TropicalFishEntity> TROPICAL_FISH;
public static final EntityDefinition<TurtleEntity> TURTLE;
public static final EntityDefinition<VexEntity> VEX;
public static final EntityDefinition<VillagerEntity> VILLAGER;
public static final EntityDefinition<VindicatorEntity> VINDICATOR;
public static final EntityDefinition<AbstractMerchantEntity> WANDERING_TRADER; public static final EntityDefinition<AbstractMerchantEntity> WANDERING_TRADER;
public static final EntityDefinition<RaidParticipantEntity> WITCH; public static final EntityDefinition<RaidParticipantEntity> WITCH;
public static final EntityDefinition<WitherEntity> WITHER; public static final EntityDefinition<WitherEntity> WITHER;
public static final EntityDefinition<AbstractSkeletonEntity> WITHER_SKELETON; public static final EntityDefinition<AbstractSkeletonEntity> WITHER_SKELETON;
public static final EntityDefinition<WitherSkullEntity> WITHER_SKULL; public static final EntityDefinition<WitherSkullEntity> WITHER_SKULL;
public static final EntityDefinition<WolfEntity> WOLF; public static final EntityDefinition<WolfEntity> WOLF;
public static final EntityDefinition<VillagerEntity> VILLAGER;
public static final EntityDefinition<VindicatorEntity> VINDICATOR;
public static final EntityDefinition<VexEntity> VEX;
public static final EntityDefinition<ZoglinEntity> ZOGLIN; public static final EntityDefinition<ZoglinEntity> ZOGLIN;
public static final EntityDefinition<ZombieEntity> ZOMBIE; public static final EntityDefinition<ZombieEntity> ZOMBIE;
public static final EntityDefinition<AbstractHorseEntity> ZOMBIE_HORSE; public static final EntityDefinition<AbstractHorseEntity> ZOMBIE_HORSE;
@ -212,13 +212,14 @@ public final class EntityDefinitions {
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingRight) .addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingRight)
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.BOAT_BUBBLE_TIME, entityMetadata.getValue())) // May not actually do anything .addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.BOAT_BUBBLE_TIME, entityMetadata.getValue())) // May not actually do anything
.build(); .build();
DRAGON_FIREBALL = EntityDefinition.inherited(ItemedFireballEntity::new, entityBase) DRAGON_FIREBALL = EntityDefinition.inherited(FireballEntity::new, entityBase)
.type(EntityType.DRAGON_FIREBALL) .type(EntityType.DRAGON_FIREBALL)
.heightAndWidth(1.0f) .heightAndWidth(1.0f)
.build(); .build();
END_CRYSTAL = EntityDefinition.inherited(EnderCrystalEntity::new, entityBase) END_CRYSTAL = EntityDefinition.inherited(EnderCrystalEntity::new, entityBase)
.type(EntityType.END_CRYSTAL) .type(EntityType.END_CRYSTAL)
.heightAndWidth(2.0f) .heightAndWidth(2.0f)
.identifier("minecraft:ender_crystal")
.addTranslator(MetadataType.OPTIONAL_POSITION, EnderCrystalEntity::setBlockTarget) .addTranslator(MetadataType.OPTIONAL_POSITION, EnderCrystalEntity::setBlockTarget)
.addTranslator(MetadataType.BOOLEAN, .addTranslator(MetadataType.BOOLEAN,
(enderCrystalEntity, entityMetadata) -> enderCrystalEntity.setFlag(EntityFlag.SHOW_BOTTOM, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue())) // There is a base located on the ender crystal (enderCrystalEntity, entityMetadata) -> enderCrystalEntity.setFlag(EntityFlag.SHOW_BOTTOM, ((BooleanEntityMetadata) entityMetadata).getPrimitiveValue())) // There is a base located on the ender crystal
@ -236,16 +237,13 @@ public final class EntityDefinitions {
.type(EntityType.EYE_OF_ENDER) .type(EntityType.EYE_OF_ENDER)
.heightAndWidth(0.25f) .heightAndWidth(0.25f)
.identifier("minecraft:eye_of_ender_signal") .identifier("minecraft:eye_of_ender_signal")
.addTranslator(null) // Item
.build(); .build();
FALLING_BLOCK = EntityDefinition.<FallingBlockEntity>inherited(null, entityBase) FALLING_BLOCK = EntityDefinition.<FallingBlockEntity>inherited(null, entityBase)
.type(EntityType.FALLING_BLOCK) .type(EntityType.FALLING_BLOCK)
.heightAndWidth(0.98f) .heightAndWidth(0.98f)
.addTranslator(null) // "start block position" .addTranslator(null) // "start block position"
.build(); .build();
FIREBALL = EntityDefinition.inherited(ItemedFireballEntity::new, entityBase)
.type(EntityType.FIREBALL)
.heightAndWidth(1.0f)
.build();
FIREWORK_ROCKET = EntityDefinition.inherited(FireworkEntity::new, entityBase) FIREWORK_ROCKET = EntityDefinition.inherited(FireworkEntity::new, entityBase)
.type(EntityType.FIREWORK_ROCKET) .type(EntityType.FIREWORK_ROCKET)
.heightAndWidth(0.25f) .heightAndWidth(0.25f)
@ -256,8 +254,9 @@ public final class EntityDefinitions {
.build(); .build();
FISHING_BOBBER = EntityDefinition.<FishingHookEntity>inherited(null, entityBase) FISHING_BOBBER = EntityDefinition.<FishingHookEntity>inherited(null, entityBase)
.type(EntityType.FISHING_BOBBER) .type(EntityType.FISHING_BOBBER)
.identifier("minecraft:fishing_book") .identifier("minecraft:fishing_hook")
.addTranslator(MetadataType.INT, FishingHookEntity::setHookedEntity) .addTranslator(MetadataType.INT, FishingHookEntity::setHookedEntity)
.addTranslator(null) // Biting TODO check
.build(); .build();
ITEM = EntityDefinition.inherited(ItemEntity::new, entityBase) ITEM = EntityDefinition.inherited(ItemEntity::new, entityBase)
.type(EntityType.ITEM) .type(EntityType.ITEM)
@ -279,44 +278,52 @@ public final class EntityDefinitions {
PAINTING = EntityDefinition.inherited((PaintingEntityFactory) PaintingEntity::new, entityBase) PAINTING = EntityDefinition.inherited((PaintingEntityFactory) PaintingEntity::new, entityBase)
.type(EntityType.PAINTING) .type(EntityType.PAINTING)
.build(); .build();
PRIMED_TNT = EntityDefinition.inherited(TNTEntity::new, entityBase)
.type(EntityType.PRIMED_TNT)
.heightAndWidth(0.98f)
.identifier("minecraft:tnt")
.addTranslator(MetadataType.INT, TNTEntity::setFuseLength)
.build();
SHULKER_BULLET = EntityDefinition.inherited(ThrowableEntity::new, entityBase) SHULKER_BULLET = EntityDefinition.inherited(ThrowableEntity::new, entityBase)
.type(EntityType.SHULKER_BULLET) .type(EntityType.SHULKER_BULLET)
.heightAndWidth(0.3125f) .heightAndWidth(0.3125f)
.build(); .build();
SMALL_FIREBALL = EntityDefinition.inherited(ItemedFireballEntity::new, entityBase) TNT = EntityDefinition.inherited(TNTEntity::new, entityBase)
.type(EntityType.TNT)
.heightAndWidth(0.98f)
.addTranslator(MetadataType.INT, TNTEntity::setFuseLength)
.build();
EntityDefinition<FireballEntity> fireballBase = EntityDefinition.inherited(FireballEntity::new, entityBase)
.addTranslator(null) // Item
.build();
FIREBALL = EntityDefinition.inherited(FireballEntity::new, fireballBase)
.type(EntityType.FIREBALL)
.heightAndWidth(1.0f)
.build();
SMALL_FIREBALL = EntityDefinition.inherited(FireballEntity::new, fireballBase)
.type(EntityType.SMALL_FIREBALL) .type(EntityType.SMALL_FIREBALL)
.heightAndWidth(0.3125f) .heightAndWidth(0.3125f)
.build(); .build();
SNOWBALL = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase)
.type(EntityType.SNOWBALL) EntityDefinition<ThrowableItemEntity> throwableItemBase = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase)
.addTranslator(MetadataType.ITEM, ThrowableItemEntity::setItem)
.build();
EGG = EntityDefinition.inherited(ThrowableItemEntity::new, throwableItemBase)
.type(EntityType.EGG)
.heightAndWidth(0.25f) .heightAndWidth(0.25f)
.build(); .build();
THROWN_ENDERPEARL = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase) ENDER_PEARL = EntityDefinition.inherited(ThrowableItemEntity::new, throwableItemBase)
.type(EntityType.THROWN_ENDERPEARL) .type(EntityType.ENDER_PEARL)
.heightAndWidth(0.25f) .heightAndWidth(0.25f)
.identifier("minecraft:ender_pearl")
.build(); .build();
THROWN_EGG = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase) EXPERIENCE_BOTTLE = EntityDefinition.inherited(ThrowableItemEntity::new, throwableItemBase)
.type(EntityType.THROWN_EGG) .type(EntityType.EXPERIENCE_BOTTLE)
.heightAndWidth(0.25f)
.identifier("minecraft:egg")
.build();
THROWN_EXP_BOTTLE = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase)
.type(EntityType.THROWN_EXP_BOTTLE)
.heightAndWidth(0.25f) .heightAndWidth(0.25f)
.identifier("minecraft:xp_bottle") .identifier("minecraft:xp_bottle")
.build(); .build();
THROWN_POTION = EntityDefinition.inherited(ThrownPotionEntity::new, entityBase) POTION = EntityDefinition.inherited(ThrownPotionEntity::new, throwableItemBase)
.type(EntityType.THROWN_POTION) .type(EntityType.POTION)
.heightAndWidth(0.25f) .heightAndWidth(0.25f)
.identifier("minecraft:splash_potion") .identifier("minecraft:splash_potion")
.addTranslator(MetadataType.ITEM, ThrownPotionEntity::setPotion) .build();
SNOWBALL = EntityDefinition.inherited(ThrowableItemEntity::new, throwableItemBase)
.type(EntityType.SNOWBALL)
.heightAndWidth(0.25f)
.build(); .build();
EntityDefinition<AbstractArrowEntity> abstractArrowBase = EntityDefinition.inherited(AbstractArrowEntity::new, entityBase) EntityDefinition<AbstractArrowEntity> abstractArrowBase = EntityDefinition.inherited(AbstractArrowEntity::new, entityBase)
@ -363,32 +370,28 @@ public final class EntityDefinitions {
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlockOffset) .addTranslator(MetadataType.INT, MinecartEntity::setCustomBlockOffset)
.addTranslator(MetadataType.BOOLEAN, MinecartEntity::setShowCustomBlock) .addTranslator(MetadataType.BOOLEAN, MinecartEntity::setShowCustomBlock)
.build(); .build();
MINECART_CHEST = EntityDefinition.inherited(MINECART.factory(), MINECART) CHEST_MINECART = EntityDefinition.inherited(MINECART.factory(), MINECART)
.type(EntityType.MINECART_CHEST) .type(EntityType.CHEST_MINECART)
.identifier("minecraft:chest_minecart")
.build(); .build();
MINECART_COMMAND_BLOCK = EntityDefinition.inherited(CommandBlockMinecartEntity::new, MINECART) COMMAND_BLOCK_MINECART = EntityDefinition.inherited(CommandBlockMinecartEntity::new, MINECART)
.type(EntityType.MINECART_COMMAND_BLOCK) .type(EntityType.COMMAND_BLOCK_MINECART)
.identifier("minecraft:command_block_minecart")
.addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_COMMAND, entityMetadata.getValue())) .addTranslator(MetadataType.STRING, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_COMMAND, entityMetadata.getValue()))
.addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue()))) .addTranslator(MetadataType.CHAT, (entity, entityMetadata) -> entity.getDirtyMetadata().put(EntityData.COMMAND_BLOCK_LAST_OUTPUT, MessageTranslator.convertMessage(entityMetadata.getValue())))
.build(); .build();
MINECART_FURNACE = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART) FURNACE_MINECART = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART)
.type(EntityType.MINECART_FURNACE) .type(EntityType.FURNACE_MINECART)
.identifier("minecraft:minecart") .identifier("minecraft:minecart")
.addTranslator(MetadataType.BOOLEAN, FurnaceMinecartEntity::setHasFuel) .addTranslator(MetadataType.BOOLEAN, FurnaceMinecartEntity::setHasFuel)
.build(); .build();
MINECART_HOPPER = EntityDefinition.inherited(MINECART.factory(), MINECART) HOPPER_MINECART = EntityDefinition.inherited(MINECART.factory(), MINECART)
.type(EntityType.MINECART_HOPPER) .type(EntityType.HOPPER_MINECART)
.identifier("minecraft:hopper_minecart")
.build(); .build();
MINECART_SPAWNER = EntityDefinition.inherited(SpawnerMinecartEntity::new, MINECART) SPAWNER_MINECART = EntityDefinition.inherited(SpawnerMinecartEntity::new, MINECART)
.type(EntityType.MINECART_SPAWNER) .type(EntityType.SPAWNER_MINECART)
.identifier("minecraft:minecart") .identifier("minecraft:minecart")
.build(); .build();
MINECART_TNT = EntityDefinition.inherited(MINECART.factory(), MINECART) TNT_MINECART = EntityDefinition.inherited(MINECART.factory(), MINECART)
.type(EntityType.MINECART_TNT) .type(EntityType.TNT_MINECART)
.identifier("minecraft:tnt_minecart")
.build(); .build();
WITHER_SKULL = EntityDefinition.inherited(WitherSkullEntity::new, entityBase) WITHER_SKULL = EntityDefinition.inherited(WitherSkullEntity::new, entityBase)
@ -451,10 +454,6 @@ public final class EntityDefinitions {
.height(1.8f).width(0.6f) .height(1.8f).width(0.6f)
.addTranslator(MetadataType.BYTE, BlazeEntity::setBlazeFlags) .addTranslator(MetadataType.BYTE, BlazeEntity::setBlazeFlags)
.build(); .build();
CAVE_SPIDER = EntityDefinition.inherited(MonsterEntity::new, mobEntityBase)
.type(EntityType.CAVE_SPIDER)
.height(0.5f).width(0.7f)
.build();
CREEPER = EntityDefinition.inherited(CreeperEntity::new, mobEntityBase) CREEPER = EntityDefinition.inherited(CreeperEntity::new, mobEntityBase)
.type(EntityType.CREEPER) .type(EntityType.CREEPER)
.height(1.7f).width(0.6f) .height(1.7f).width(0.6f)
@ -536,6 +535,10 @@ public final class EntityDefinitions {
.offset(1f) .offset(1f)
.addTranslator(MetadataType.BYTE, SpiderEntity::setSpiderFlags) .addTranslator(MetadataType.BYTE, SpiderEntity::setSpiderFlags)
.build(); .build();
CAVE_SPIDER = EntityDefinition.inherited(SpiderEntity::new, SPIDER)
.type(EntityType.CAVE_SPIDER)
.height(0.5f).width(0.7f)
.build();
SQUID = EntityDefinition.inherited(SquidEntity::new, mobEntityBase) SQUID = EntityDefinition.inherited(SquidEntity::new, mobEntityBase)
.type(EntityType.SQUID) .type(EntityType.SQUID)
.heightAndWidth(0.8f) .heightAndWidth(0.8f)
@ -732,6 +735,8 @@ public final class EntityDefinitions {
.height(0.5f).width(1.25f) .height(0.5f).width(1.25f)
.addTranslator(MetadataType.INT, FoxEntity::setFoxVariant) .addTranslator(MetadataType.INT, FoxEntity::setFoxVariant)
.addTranslator(MetadataType.BYTE, FoxEntity::setFoxFlags) .addTranslator(MetadataType.BYTE, FoxEntity::setFoxFlags)
.addTranslator(null) // Trusted player 1
.addTranslator(null) // Trusted player 2
.build(); .build();
HOGLIN = EntityDefinition.inherited(HoglinEntity::new, ageableEntityBase) HOGLIN = EntityDefinition.inherited(HoglinEntity::new, ageableEntityBase)
.type(EntityType.HOGLIN) .type(EntityType.HOGLIN)
@ -891,7 +896,7 @@ public final class EntityDefinitions {
// As of 1.18 these don't track entity data at all // As of 1.18 these don't track entity data at all
ENDER_DRAGON_PART = EntityDefinition.<EnderDragonPartEntity>builder(null) ENDER_DRAGON_PART = EntityDefinition.<EnderDragonPartEntity>builder(null)
.identifier("minecraft:armor_stand") // Emulated .identifier("minecraft:armor_stand") // Emulated
.build(); .build(false); // Never sent over the network
Registries.JAVA_ENTITY_IDENTIFIERS.get().put("minecraft:marker", null); // We don't need an entity definition for this as it is never sent over the network Registries.JAVA_ENTITY_IDENTIFIERS.get().put("minecraft:marker", null); // We don't need an entity definition for this as it is never sent over the network
} }

Datei anzeigen

@ -162,9 +162,9 @@ public class InteractiveTagManager {
interactiveTag = InteractiveTag.RIDE_MINECART; interactiveTag = InteractiveTag.RIDE_MINECART;
} }
break; break;
case MINECART_CHEST: case CHEST_MINECART:
case MINECART_COMMAND_BLOCK: case COMMAND_BLOCK_MINECART:
case MINECART_HOPPER: case HOPPER_MINECART:
interactiveTag = InteractiveTag.OPEN_CONTAINER; interactiveTag = InteractiveTag.OPEN_CONTAINER;
break; break;
case PIG: case PIG:

Datei anzeigen

@ -30,6 +30,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.BooleanEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.ByteEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata; import com.github.steveice10.mc.protocol.data.game.entity.metadata.type.IntEntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityData; import com.nukkitx.protocol.bedrock.data.entity.EntityData;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
@ -159,7 +160,11 @@ public class Entity {
flagsDirty = false; flagsDirty = false;
session.getGeyser().getLogger().debug("Spawned entity " + getClass().getName() + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); if (session.getGeyser().getConfig().isDebugMode()) {
EntityType type = definition.entityType();
String name = type != null ? type.name() : getClass().getSimpleName();
session.getGeyser().getLogger().debug("Spawned entity " + name + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")");
}
} }
/** /**
@ -402,7 +407,7 @@ public class Entity {
public float setFreezing(IntEntityMetadata entityMetadata) { public float setFreezing(IntEntityMetadata entityMetadata) {
// The value that Java edition gives us is in ticks, but Bedrock uses a float percentage of the strength 0.0 -> 1.0 // The value that Java edition gives us is in ticks, but Bedrock uses a float percentage of the strength 0.0 -> 1.0
// The Java client caps its freezing tick percentage at 140 // The Java client caps its freezing tick percentage at 140
int freezingTicks = Math.min(((IntEntityMetadata) entityMetadata).getPrimitiveValue(), 140); int freezingTicks = Math.min(entityMetadata.getPrimitiveValue(), 140);
float freezingPercentage = freezingTicks / 140f; float freezingPercentage = freezingTicks / 140f;
dirtyMetadata.put(EntityData.FREEZING_EFFECT_STRENGTH, freezingPercentage); dirtyMetadata.put(EntityData.FREEZING_EFFECT_STRENGTH, freezingPercentage);
return freezingPercentage; return freezingPercentage;

Datei anzeigen

@ -32,17 +32,9 @@ import org.geysermc.geyser.session.GeyserSession;
public class ExpOrbEntity extends Entity { public class ExpOrbEntity extends Entity {
private final int amount;
public ExpOrbEntity(GeyserSession session, int amount, long entityId, long geyserId, Vector3f position) { public ExpOrbEntity(GeyserSession session, int amount, long entityId, long geyserId, Vector3f position) {
super(session, entityId, geyserId, null, EntityDefinitions.EXPERIENCE_ORB, position, Vector3f.ZERO, 0, 0, 0); super(session, entityId, geyserId, null, EntityDefinitions.EXPERIENCE_ORB, position, Vector3f.ZERO, 0, 0, 0);
this.amount = amount;
}
@Override
protected void initializeMetadata() {
super.initializeMetadata();
this.dirtyMetadata.put(EntityData.EXPERIENCE_VALUE, amount); this.dirtyMetadata.put(EntityData.EXPERIENCE_VALUE, amount);
} }
} }

Datei anzeigen

@ -35,16 +35,10 @@ import org.geysermc.geyser.session.GeyserSession;
import java.util.UUID; import java.util.UUID;
public class FallingBlockEntity extends Entity { public class FallingBlockEntity extends Entity {
private final int javaId;
public FallingBlockEntity(GeyserSession session, long entityId, long geyserId, UUID uuid, Vector3f position, Vector3f motion, float yaw, float pitch, int javaId) { public FallingBlockEntity(GeyserSession session, long entityId, long geyserId, UUID uuid, Vector3f position, Vector3f motion, float yaw, float pitch, int javaId) {
super(session, entityId, geyserId, uuid, EntityDefinitions.FALLING_BLOCK, position, motion, yaw, pitch, 0f); super(session, entityId, geyserId, uuid, EntityDefinitions.FALLING_BLOCK, position, motion, yaw, pitch, 0f);
this.javaId = javaId;
}
@Override
protected void initializeMetadata() {
super.initializeMetadata();
this.dirtyMetadata.put(EntityData.VARIANT, session.getBlockMappings().getBedrockBlockId(javaId)); this.dirtyMetadata.put(EntityData.VARIANT, session.getBlockMappings().getBedrockBlockId(javaId));
} }

Datei anzeigen

@ -31,7 +31,7 @@ import org.geysermc.geyser.session.GeyserSession;
import java.util.UUID; import java.util.UUID;
public class ItemedFireballEntity extends ThrowableEntity { public class FireballEntity extends ThrowableEntity {
private final Vector3f acceleration; private final Vector3f acceleration;
/** /**
@ -39,7 +39,7 @@ public class ItemedFireballEntity extends ThrowableEntity {
*/ */
protected int futureTicks = 3; protected int futureTicks = 3;
public ItemedFireballEntity(GeyserSession session, long entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) { public FireballEntity(GeyserSession session, long entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {
super(session, entityId, geyserId, uuid, definition, position, Vector3f.ZERO, yaw, pitch, headYaw); super(session, entityId, geyserId, uuid, definition, position, Vector3f.ZERO, yaw, pitch, headYaw);
float magnitude = motion.length(); float magnitude = motion.length();

Datei anzeigen

@ -118,16 +118,16 @@ public class ThrowableEntity extends Entity implements Tickable {
protected float getGravity() { protected float getGravity() {
if (getFlag(EntityFlag.HAS_GRAVITY)) { if (getFlag(EntityFlag.HAS_GRAVITY)) {
switch (definition.entityType()) { switch (definition.entityType()) {
case THROWN_POTION: case POTION:
return 0.05f; return 0.05f;
case THROWN_EXP_BOTTLE: case EXPERIENCE_BOTTLE:
return 0.07f; return 0.07f;
case FIREBALL: case FIREBALL:
case SHULKER_BULLET: case SHULKER_BULLET:
return 0; return 0;
case SNOWBALL: case SNOWBALL:
case THROWN_EGG: case EGG:
case THROWN_ENDERPEARL: case ENDER_PEARL:
return 0.03f; return 0.03f;
case LLAMA_SPIT: case LLAMA_SPIT:
return 0.06f; return 0.06f;
@ -144,11 +144,11 @@ public class ThrowableEntity extends Entity implements Tickable {
return 0.8f; return 0.8f;
} else { } else {
switch (definition.entityType()) { switch (definition.entityType()) {
case THROWN_POTION: case POTION:
case THROWN_EXP_BOTTLE: case EXPERIENCE_BOTTLE:
case SNOWBALL: case SNOWBALL:
case THROWN_EGG: case EGG:
case THROWN_ENDERPEARL: case ENDER_PEARL:
case LLAMA_SPIT: case LLAMA_SPIT:
return 0.99f; return 0.99f;
case FIREBALL: case FIREBALL:
@ -172,7 +172,7 @@ public class ThrowableEntity extends Entity implements Tickable {
@Override @Override
public boolean despawnEntity() { public boolean despawnEntity() {
if (definition.entityType() == EntityType.THROWN_ENDERPEARL) { if (definition.entityType() == EntityType.ENDER_PEARL) {
LevelEventPacket particlePacket = new LevelEventPacket(); LevelEventPacket particlePacket = new LevelEventPacket();
particlePacket.setType(LevelEventType.PARTICLE_TELEPORT); particlePacket.setType(LevelEventType.PARTICLE_TELEPORT);
particlePacket.setPosition(position); particlePacket.setPosition(position);

Datei anzeigen

@ -25,6 +25,8 @@
package org.geysermc.geyser.entity.type; package org.geysermc.geyser.entity.type;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag; import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
import org.geysermc.geyser.entity.EntityDefinition; import org.geysermc.geyser.entity.EntityDefinition;
@ -75,4 +77,7 @@ public class ThrowableItemEntity extends ThrowableEntity {
protected void setInvisible(boolean value) { protected void setInvisible(boolean value) {
invisible = value; invisible = value;
} }
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
}
} }

Datei anzeigen

@ -48,8 +48,14 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw); super(session, entityId, geyserId, uuid, definition, position, motion, yaw, pitch, headYaw);
} }
public void setPotion(EntityMetadata<ItemStack, ?> entityMetadata) { @Override
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
ItemStack itemStack = entityMetadata.getValue(); ItemStack itemStack = entityMetadata.getValue();
if (itemStack == null) {
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, 0);
setFlag(EntityFlag.ENCHANTED, false);
setFlag(EntityFlag.LINGERING, false);
} else {
ItemMapping mapping = session.getItemMappings().getMapping(itemStack); ItemMapping mapping = session.getItemMappings().getMapping(itemStack);
if (mapping.getJavaIdentifier().endsWith("potion") && itemStack.getNbt() != null) { if (mapping.getJavaIdentifier().endsWith("potion") && itemStack.getNbt() != null) {
Tag potionTag = itemStack.getNbt().get("Potion"); Tag potionTag = itemStack.getNbt().get("Potion");
@ -68,4 +74,5 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
setFlag(EntityFlag.LINGERING, isLingering); setFlag(EntityFlag.LINGERING, isLingering);
} }
} }
}
} }

Datei anzeigen

@ -33,7 +33,7 @@ import org.geysermc.geyser.session.GeyserSession;
import java.util.UUID; import java.util.UUID;
public class WitherSkullEntity extends ItemedFireballEntity { public class WitherSkullEntity extends FireballEntity {
private boolean isCharged; private boolean isCharged;
public WitherSkullEntity(GeyserSession session, long entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) { public WitherSkullEntity(GeyserSession session, long entityId, long geyserId, UUID uuid, EntityDefinition<?> definition, Vector3f position, Vector3f motion, float yaw, float pitch, float headYaw) {

Datei anzeigen

@ -66,11 +66,11 @@ public class BedrockEntityPickRequestTranslator extends PacketTranslator<EntityP
itemName = typeOfBoat + "_boat"; itemName = typeOfBoat + "_boat";
} }
case LEASH_KNOT -> itemName = "lead"; case LEASH_KNOT -> itemName = "lead";
case MINECART_CHEST, MINECART_COMMAND_BLOCK, MINECART_FURNACE, MINECART_HOPPER, MINECART_TNT -> case CHEST_MINECART, COMMAND_BLOCK_MINECART, FURNACE_MINECART, HOPPER_MINECART, TNT_MINECART ->
// The Bedrock identifier matches the item name which moves MINECART to the end of the name // The Bedrock identifier matches the item name which moves MINECART to the end of the name
// TODO test // TODO test
itemName = entity.getDefinition().identifier(); itemName = entity.getDefinition().identifier();
case MINECART_SPAWNER -> itemName = "minecart"; // Turns into a normal minecart case SPAWNER_MINECART -> itemName = "minecart"; // Turns into a normal minecart
//case ITEM_FRAME -> Not an entity in Bedrock Edition //case ITEM_FRAME -> Not an entity in Bedrock Edition
//case GLOW_ITEM_FRAME -> //case GLOW_ITEM_FRAME ->
case ARMOR_STAND, END_CRYSTAL, MINECART, PAINTING -> case ARMOR_STAND, END_CRYSTAL, MINECART, PAINTING ->

Datei anzeigen

@ -97,7 +97,7 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
break; break;
case LIVING_DEATH: case LIVING_DEATH:
entityEventPacket.setType(EntityEventType.DEATH); entityEventPacket.setType(EntityEventType.DEATH);
if (entity.getDefinition() == EntityDefinitions.THROWN_EGG) { if (entity.getDefinition() == EntityDefinitions.EGG) {
LevelEventPacket particlePacket = new LevelEventPacket(); LevelEventPacket particlePacket = new LevelEventPacket();
particlePacket.setType(LevelEventType.PARTICLE_ITEM_BREAK); particlePacket.setType(LevelEventType.PARTICLE_ITEM_BREAK);
particlePacket.setData(session.getItemMappings().getStoredItems().egg().getBedrockId() << 16); particlePacket.setData(session.getItemMappings().getStoredItems().egg().getBedrockId() << 16);

Datei anzeigen

@ -75,8 +75,8 @@ public final class EntityUtils {
case CHICKEN, SPIDER -> mountedHeightOffset = height * 0.5f; case CHICKEN, SPIDER -> mountedHeightOffset = height * 0.5f;
case DONKEY, MULE -> mountedHeightOffset -= 0.25f; case DONKEY, MULE -> mountedHeightOffset -= 0.25f;
case LLAMA -> mountedHeightOffset = height * 0.67f; case LLAMA -> mountedHeightOffset = height * 0.67f;
case MINECART, MINECART_HOPPER, MINECART_TNT, MINECART_CHEST, MINECART_FURNACE, MINECART_SPAWNER, case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
MINECART_COMMAND_BLOCK -> mountedHeightOffset = 0; COMMAND_BLOCK_MINECART -> mountedHeightOffset = 0;
case BOAT -> mountedHeightOffset = -0.1f; case BOAT -> mountedHeightOffset = -0.1f;
case HOGLIN, ZOGLIN -> { case HOGLIN, ZOGLIN -> {
boolean isBaby = mount.getFlag(EntityFlag.BABY); boolean isBaby = mount.getFlag(EntityFlag.BABY);
@ -169,8 +169,8 @@ public final class EntityUtils {
yOffset += EntityDefinitions.PLAYER.offset(); yOffset += EntityDefinitions.PLAYER.offset();
} }
switch (mount.getDefinition().entityType()) { switch (mount.getDefinition().entityType()) {
case MINECART, MINECART_HOPPER, MINECART_TNT, MINECART_CHEST, MINECART_FURNACE, MINECART_SPAWNER, case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
MINECART_COMMAND_BLOCK, BOAT -> yOffset -= mount.getDefinition().height() * 0.5f; COMMAND_BLOCK_MINECART, BOAT -> yOffset -= mount.getDefinition().height() * 0.5f;
} }
Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset); Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset);
passenger.setRiderSeatPosition(offset); passenger.setRiderSeatPosition(offset);