mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-29 15:49:09 +01: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
This commit is contained in:
parent
0d7bf7b71a
commit
a305c22665
14 changed files with 135 additions and 127 deletions
|
@ -155,7 +155,7 @@
|
|||
<dependency>
|
||||
<groupId>com.github.GeyserMC</groupId>
|
||||
<artifactId>MCProtocolLib</artifactId>
|
||||
<version>7f7808e2</version>
|
||||
<version>f7f84e7</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
|
|
@ -63,36 +63,43 @@ public final class EntityDefinitions {
|
|||
public static final EntityDefinition<BlazeEntity> BLAZE;
|
||||
public static final EntityDefinition<BoatEntity> BOAT;
|
||||
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<CreeperEntity> CREEPER;
|
||||
public static final EntityDefinition<AbstractFishEntity> COD;
|
||||
public static final EntityDefinition<CommandBlockMinecartEntity> COMMAND_BLOCK_MINECART;
|
||||
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<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<ThrowableItemEntity> EGG;
|
||||
public static final EntityDefinition<ElderGuardianEntity> ELDER_GUARDIAN;
|
||||
public static final EntityDefinition<EndermanEntity> ENDERMAN;
|
||||
public static final EntityDefinition<MonsterEntity> ENDERMITE;
|
||||
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<SpellcasterIllagerEntity> EVOKER;
|
||||
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<Entity> EYE_OF_ENDER;
|
||||
public static final EntityDefinition<FallingBlockEntity> FALLING_BLOCK;
|
||||
public static final EntityDefinition<ItemedFireballEntity> FIREBALL;
|
||||
public static final EntityDefinition<FishingHookEntity> FISHING_BOBBER;
|
||||
public static final EntityDefinition<FireballEntity> FIREBALL;
|
||||
public static final EntityDefinition<FireworkEntity> FIREWORK_ROCKET;
|
||||
public static final EntityDefinition<FishingHookEntity> FISHING_BOBBER;
|
||||
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<GiantEntity> GIANT;
|
||||
public static final EntityDefinition<ItemFrameEntity> GLOW_ITEM_FRAME;
|
||||
public static final EntityDefinition<GlowSquidEntity> GLOW_SQUID;
|
||||
public static final EntityDefinition<GoatEntity> GOAT;
|
||||
public static final EntityDefinition<GuardianEntity> GUARDIAN;
|
||||
public static final EntityDefinition<HoglinEntity> HOGLIN;
|
||||
public static final EntityDefinition<MinecartEntity> HOPPER_MINECART;
|
||||
public static final EntityDefinition<HorseEntity> HORSE;
|
||||
public static final EntityDefinition<ZombieEntity> HUSK;
|
||||
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<MagmaCubeEntity> MAGMA_CUBE;
|
||||
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<ChestedHorseEntity> MULE;
|
||||
public static final EntityDefinition<OcelotEntity> OCELOT;
|
||||
|
@ -124,7 +125,7 @@ public final class EntityDefinitions {
|
|||
public static final EntityDefinition<PillagerEntity> PILLAGER;
|
||||
public static final EntityDefinition<PlayerEntity> PLAYER;
|
||||
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<RabbitEntity> RABBIT;
|
||||
public static final EntityDefinition<RaidParticipantEntity> RAVAGER;
|
||||
|
@ -136,31 +137,30 @@ public final class EntityDefinitions {
|
|||
public static final EntityDefinition<SkeletonEntity> SKELETON;
|
||||
public static final EntityDefinition<AbstractHorseEntity> SKELETON_HORSE;
|
||||
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<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<SpiderEntity> SPIDER;
|
||||
public static final EntityDefinition<SquidEntity> SQUID;
|
||||
public static final EntityDefinition<AbstractSkeletonEntity> STRAY;
|
||||
public static final EntityDefinition<StriderEntity> STRIDER;
|
||||
public static final EntityDefinition<ThrowableItemEntity> THROWN_EGG;
|
||||
public static final EntityDefinition<ThrowableItemEntity> THROWN_ENDERPEARL;
|
||||
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<TNTEntity> TNT;
|
||||
public static final EntityDefinition<MinecartEntity> TNT_MINECART;
|
||||
public static final EntityDefinition<TraderLlamaEntity> TRADER_LLAMA;
|
||||
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<RaidParticipantEntity> WITCH;
|
||||
public static final EntityDefinition<WitherEntity> WITHER;
|
||||
public static final EntityDefinition<AbstractSkeletonEntity> WITHER_SKELETON;
|
||||
public static final EntityDefinition<WitherSkullEntity> WITHER_SKULL;
|
||||
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<ZombieEntity> ZOMBIE;
|
||||
public static final EntityDefinition<AbstractHorseEntity> ZOMBIE_HORSE;
|
||||
|
@ -212,13 +212,14 @@ public final class EntityDefinitions {
|
|||
.addTranslator(MetadataType.BOOLEAN, BoatEntity::setPaddlingRight)
|
||||
.addTranslator(MetadataType.INT, (boatEntity, entityMetadata) -> boatEntity.getDirtyMetadata().put(EntityData.BOAT_BUBBLE_TIME, entityMetadata.getValue())) // May not actually do anything
|
||||
.build();
|
||||
DRAGON_FIREBALL = EntityDefinition.inherited(ItemedFireballEntity::new, entityBase)
|
||||
DRAGON_FIREBALL = EntityDefinition.inherited(FireballEntity::new, entityBase)
|
||||
.type(EntityType.DRAGON_FIREBALL)
|
||||
.heightAndWidth(1.0f)
|
||||
.build();
|
||||
END_CRYSTAL = EntityDefinition.inherited(EnderCrystalEntity::new, entityBase)
|
||||
.type(EntityType.END_CRYSTAL)
|
||||
.heightAndWidth(2.0f)
|
||||
.identifier("minecraft:ender_crystal")
|
||||
.addTranslator(MetadataType.OPTIONAL_POSITION, EnderCrystalEntity::setBlockTarget)
|
||||
.addTranslator(MetadataType.BOOLEAN,
|
||||
(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)
|
||||
.heightAndWidth(0.25f)
|
||||
.identifier("minecraft:eye_of_ender_signal")
|
||||
.addTranslator(null) // Item
|
||||
.build();
|
||||
FALLING_BLOCK = EntityDefinition.<FallingBlockEntity>inherited(null, entityBase)
|
||||
.type(EntityType.FALLING_BLOCK)
|
||||
.heightAndWidth(0.98f)
|
||||
.addTranslator(null) // "start block position"
|
||||
.build();
|
||||
FIREBALL = EntityDefinition.inherited(ItemedFireballEntity::new, entityBase)
|
||||
.type(EntityType.FIREBALL)
|
||||
.heightAndWidth(1.0f)
|
||||
.build();
|
||||
FIREWORK_ROCKET = EntityDefinition.inherited(FireworkEntity::new, entityBase)
|
||||
.type(EntityType.FIREWORK_ROCKET)
|
||||
.heightAndWidth(0.25f)
|
||||
|
@ -256,8 +254,9 @@ public final class EntityDefinitions {
|
|||
.build();
|
||||
FISHING_BOBBER = EntityDefinition.<FishingHookEntity>inherited(null, entityBase)
|
||||
.type(EntityType.FISHING_BOBBER)
|
||||
.identifier("minecraft:fishing_book")
|
||||
.identifier("minecraft:fishing_hook")
|
||||
.addTranslator(MetadataType.INT, FishingHookEntity::setHookedEntity)
|
||||
.addTranslator(null) // Biting TODO check
|
||||
.build();
|
||||
ITEM = EntityDefinition.inherited(ItemEntity::new, entityBase)
|
||||
.type(EntityType.ITEM)
|
||||
|
@ -279,44 +278,52 @@ public final class EntityDefinitions {
|
|||
PAINTING = EntityDefinition.inherited((PaintingEntityFactory) PaintingEntity::new, entityBase)
|
||||
.type(EntityType.PAINTING)
|
||||
.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)
|
||||
.type(EntityType.SHULKER_BULLET)
|
||||
.heightAndWidth(0.3125f)
|
||||
.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)
|
||||
.heightAndWidth(0.3125f)
|
||||
.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)
|
||||
.build();
|
||||
THROWN_ENDERPEARL = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase)
|
||||
.type(EntityType.THROWN_ENDERPEARL)
|
||||
ENDER_PEARL = EntityDefinition.inherited(ThrowableItemEntity::new, throwableItemBase)
|
||||
.type(EntityType.ENDER_PEARL)
|
||||
.heightAndWidth(0.25f)
|
||||
.identifier("minecraft:ender_pearl")
|
||||
.build();
|
||||
THROWN_EGG = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase)
|
||||
.type(EntityType.THROWN_EGG)
|
||||
.heightAndWidth(0.25f)
|
||||
.identifier("minecraft:egg")
|
||||
.build();
|
||||
THROWN_EXP_BOTTLE = EntityDefinition.inherited(ThrowableItemEntity::new, entityBase)
|
||||
.type(EntityType.THROWN_EXP_BOTTLE)
|
||||
EXPERIENCE_BOTTLE = EntityDefinition.inherited(ThrowableItemEntity::new, throwableItemBase)
|
||||
.type(EntityType.EXPERIENCE_BOTTLE)
|
||||
.heightAndWidth(0.25f)
|
||||
.identifier("minecraft:xp_bottle")
|
||||
.build();
|
||||
THROWN_POTION = EntityDefinition.inherited(ThrownPotionEntity::new, entityBase)
|
||||
.type(EntityType.THROWN_POTION)
|
||||
POTION = EntityDefinition.inherited(ThrownPotionEntity::new, throwableItemBase)
|
||||
.type(EntityType.POTION)
|
||||
.heightAndWidth(0.25f)
|
||||
.identifier("minecraft:splash_potion")
|
||||
.addTranslator(MetadataType.ITEM, ThrownPotionEntity::setPotion)
|
||||
.build();
|
||||
SNOWBALL = EntityDefinition.inherited(ThrowableItemEntity::new, throwableItemBase)
|
||||
.type(EntityType.SNOWBALL)
|
||||
.heightAndWidth(0.25f)
|
||||
.build();
|
||||
|
||||
EntityDefinition<AbstractArrowEntity> abstractArrowBase = EntityDefinition.inherited(AbstractArrowEntity::new, entityBase)
|
||||
|
@ -363,32 +370,28 @@ public final class EntityDefinitions {
|
|||
.addTranslator(MetadataType.INT, MinecartEntity::setCustomBlockOffset)
|
||||
.addTranslator(MetadataType.BOOLEAN, MinecartEntity::setShowCustomBlock)
|
||||
.build();
|
||||
MINECART_CHEST = EntityDefinition.inherited(MINECART.factory(), MINECART)
|
||||
.type(EntityType.MINECART_CHEST)
|
||||
.identifier("minecraft:chest_minecart")
|
||||
CHEST_MINECART = EntityDefinition.inherited(MINECART.factory(), MINECART)
|
||||
.type(EntityType.CHEST_MINECART)
|
||||
.build();
|
||||
MINECART_COMMAND_BLOCK = EntityDefinition.inherited(CommandBlockMinecartEntity::new, MINECART)
|
||||
.type(EntityType.MINECART_COMMAND_BLOCK)
|
||||
.identifier("minecraft:command_block_minecart")
|
||||
COMMAND_BLOCK_MINECART = EntityDefinition.inherited(CommandBlockMinecartEntity::new, MINECART)
|
||||
.type(EntityType.COMMAND_BLOCK_MINECART)
|
||||
.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())))
|
||||
.build();
|
||||
MINECART_FURNACE = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART)
|
||||
.type(EntityType.MINECART_FURNACE)
|
||||
FURNACE_MINECART = EntityDefinition.inherited(FurnaceMinecartEntity::new, MINECART)
|
||||
.type(EntityType.FURNACE_MINECART)
|
||||
.identifier("minecraft:minecart")
|
||||
.addTranslator(MetadataType.BOOLEAN, FurnaceMinecartEntity::setHasFuel)
|
||||
.build();
|
||||
MINECART_HOPPER = EntityDefinition.inherited(MINECART.factory(), MINECART)
|
||||
.type(EntityType.MINECART_HOPPER)
|
||||
.identifier("minecraft:hopper_minecart")
|
||||
HOPPER_MINECART = EntityDefinition.inherited(MINECART.factory(), MINECART)
|
||||
.type(EntityType.HOPPER_MINECART)
|
||||
.build();
|
||||
MINECART_SPAWNER = EntityDefinition.inherited(SpawnerMinecartEntity::new, MINECART)
|
||||
.type(EntityType.MINECART_SPAWNER)
|
||||
SPAWNER_MINECART = EntityDefinition.inherited(SpawnerMinecartEntity::new, MINECART)
|
||||
.type(EntityType.SPAWNER_MINECART)
|
||||
.identifier("minecraft:minecart")
|
||||
.build();
|
||||
MINECART_TNT = EntityDefinition.inherited(MINECART.factory(), MINECART)
|
||||
.type(EntityType.MINECART_TNT)
|
||||
.identifier("minecraft:tnt_minecart")
|
||||
TNT_MINECART = EntityDefinition.inherited(MINECART.factory(), MINECART)
|
||||
.type(EntityType.TNT_MINECART)
|
||||
.build();
|
||||
|
||||
WITHER_SKULL = EntityDefinition.inherited(WitherSkullEntity::new, entityBase)
|
||||
|
@ -451,10 +454,6 @@ public final class EntityDefinitions {
|
|||
.height(1.8f).width(0.6f)
|
||||
.addTranslator(MetadataType.BYTE, BlazeEntity::setBlazeFlags)
|
||||
.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)
|
||||
.type(EntityType.CREEPER)
|
||||
.height(1.7f).width(0.6f)
|
||||
|
@ -536,6 +535,10 @@ public final class EntityDefinitions {
|
|||
.offset(1f)
|
||||
.addTranslator(MetadataType.BYTE, SpiderEntity::setSpiderFlags)
|
||||
.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)
|
||||
.type(EntityType.SQUID)
|
||||
.heightAndWidth(0.8f)
|
||||
|
@ -732,6 +735,8 @@ public final class EntityDefinitions {
|
|||
.height(0.5f).width(1.25f)
|
||||
.addTranslator(MetadataType.INT, FoxEntity::setFoxVariant)
|
||||
.addTranslator(MetadataType.BYTE, FoxEntity::setFoxFlags)
|
||||
.addTranslator(null) // Trusted player 1
|
||||
.addTranslator(null) // Trusted player 2
|
||||
.build();
|
||||
HOGLIN = EntityDefinition.inherited(HoglinEntity::new, ageableEntityBase)
|
||||
.type(EntityType.HOGLIN)
|
||||
|
@ -891,7 +896,7 @@ public final class EntityDefinitions {
|
|||
// As of 1.18 these don't track entity data at all
|
||||
ENDER_DRAGON_PART = EntityDefinition.<EnderDragonPartEntity>builder(null)
|
||||
.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
|
||||
}
|
||||
|
|
|
@ -162,9 +162,9 @@ public class InteractiveTagManager {
|
|||
interactiveTag = InteractiveTag.RIDE_MINECART;
|
||||
}
|
||||
break;
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND_BLOCK:
|
||||
case MINECART_HOPPER:
|
||||
case CHEST_MINECART:
|
||||
case COMMAND_BLOCK_MINECART:
|
||||
case HOPPER_MINECART:
|
||||
interactiveTag = InteractiveTag.OPEN_CONTAINER;
|
||||
break;
|
||||
case PIG:
|
||||
|
|
|
@ -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.ByteEntityMetadata;
|
||||
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.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -159,7 +160,11 @@ public class Entity {
|
|||
|
||||
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) {
|
||||
// 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
|
||||
int freezingTicks = Math.min(((IntEntityMetadata) entityMetadata).getPrimitiveValue(), 140);
|
||||
int freezingTicks = Math.min(entityMetadata.getPrimitiveValue(), 140);
|
||||
float freezingPercentage = freezingTicks / 140f;
|
||||
dirtyMetadata.put(EntityData.FREEZING_EFFECT_STRENGTH, freezingPercentage);
|
||||
return freezingPercentage;
|
||||
|
|
|
@ -32,17 +32,9 @@ import org.geysermc.geyser.session.GeyserSession;
|
|||
|
||||
public class ExpOrbEntity extends Entity {
|
||||
|
||||
private final int amount;
|
||||
|
||||
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);
|
||||
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeMetadata() {
|
||||
super.initializeMetadata();
|
||||
this.dirtyMetadata.put(EntityData.EXPERIENCE_VALUE, amount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,16 +35,10 @@ import org.geysermc.geyser.session.GeyserSession;
|
|||
import java.util.UUID;
|
||||
|
||||
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) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ import org.geysermc.geyser.session.GeyserSession;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ItemedFireballEntity extends ThrowableEntity {
|
||||
public class FireballEntity extends ThrowableEntity {
|
||||
private final Vector3f acceleration;
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ public class ItemedFireballEntity extends ThrowableEntity {
|
|||
*/
|
||||
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);
|
||||
|
||||
float magnitude = motion.length();
|
|
@ -118,16 +118,16 @@ public class ThrowableEntity extends Entity implements Tickable {
|
|||
protected float getGravity() {
|
||||
if (getFlag(EntityFlag.HAS_GRAVITY)) {
|
||||
switch (definition.entityType()) {
|
||||
case THROWN_POTION:
|
||||
case POTION:
|
||||
return 0.05f;
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case EXPERIENCE_BOTTLE:
|
||||
return 0.07f;
|
||||
case FIREBALL:
|
||||
case SHULKER_BULLET:
|
||||
return 0;
|
||||
case SNOWBALL:
|
||||
case THROWN_EGG:
|
||||
case THROWN_ENDERPEARL:
|
||||
case EGG:
|
||||
case ENDER_PEARL:
|
||||
return 0.03f;
|
||||
case LLAMA_SPIT:
|
||||
return 0.06f;
|
||||
|
@ -144,11 +144,11 @@ public class ThrowableEntity extends Entity implements Tickable {
|
|||
return 0.8f;
|
||||
} else {
|
||||
switch (definition.entityType()) {
|
||||
case THROWN_POTION:
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case POTION:
|
||||
case EXPERIENCE_BOTTLE:
|
||||
case SNOWBALL:
|
||||
case THROWN_EGG:
|
||||
case THROWN_ENDERPEARL:
|
||||
case EGG:
|
||||
case ENDER_PEARL:
|
||||
case LLAMA_SPIT:
|
||||
return 0.99f;
|
||||
case FIREBALL:
|
||||
|
@ -172,7 +172,7 @@ public class ThrowableEntity extends Entity implements Tickable {
|
|||
|
||||
@Override
|
||||
public boolean despawnEntity() {
|
||||
if (definition.entityType() == EntityType.THROWN_ENDERPEARL) {
|
||||
if (definition.entityType() == EntityType.ENDER_PEARL) {
|
||||
LevelEventPacket particlePacket = new LevelEventPacket();
|
||||
particlePacket.setType(LevelEventType.PARTICLE_TELEPORT);
|
||||
particlePacket.setPosition(position);
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
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.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.entity.EntityDefinition;
|
||||
|
@ -75,4 +77,7 @@ public class ThrowableItemEntity extends ThrowableEntity {
|
|||
protected void setInvisible(boolean value) {
|
||||
invisible = value;
|
||||
}
|
||||
|
||||
public void setItem(EntityMetadata<ItemStack, ?> entityMetadata) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,24 +48,31 @@ public class ThrownPotionEntity extends ThrowableItemEntity {
|
|||
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();
|
||||
ItemMapping mapping = session.getItemMappings().getMapping(itemStack);
|
||||
if (mapping.getJavaIdentifier().endsWith("potion") && itemStack.getNbt() != null) {
|
||||
Tag potionTag = itemStack.getNbt().get("Potion");
|
||||
if (potionTag instanceof StringTag) {
|
||||
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
|
||||
if (potion != null) {
|
||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, potion.getBedrockId());
|
||||
setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion));
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, 0);
|
||||
GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionTag.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);
|
||||
if (mapping.getJavaIdentifier().endsWith("potion") && itemStack.getNbt() != null) {
|
||||
Tag potionTag = itemStack.getNbt().get("Potion");
|
||||
if (potionTag instanceof StringTag) {
|
||||
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
|
||||
if (potion != null) {
|
||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, potion.getBedrockId());
|
||||
setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion));
|
||||
} else {
|
||||
dirtyMetadata.put(EntityData.POTION_AUX_VALUE, 0);
|
||||
GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionTag.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isLingering = mapping.getJavaIdentifier().equals("minecraft:lingering_potion");
|
||||
setFlag(EntityFlag.LINGERING, isLingering);
|
||||
boolean isLingering = mapping.getJavaIdentifier().equals("minecraft:lingering_potion");
|
||||
setFlag(EntityFlag.LINGERING, isLingering);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import org.geysermc.geyser.session.GeyserSession;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
public class WitherSkullEntity extends ItemedFireballEntity {
|
||||
public class WitherSkullEntity extends FireballEntity {
|
||||
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) {
|
||||
|
|
|
@ -66,11 +66,11 @@ public class BedrockEntityPickRequestTranslator extends PacketTranslator<EntityP
|
|||
itemName = typeOfBoat + "_boat";
|
||||
}
|
||||
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
|
||||
// TODO test
|
||||
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 GLOW_ITEM_FRAME ->
|
||||
case ARMOR_STAND, END_CRYSTAL, MINECART, PAINTING ->
|
||||
|
|
|
@ -97,7 +97,7 @@ public class JavaEntityEventTranslator extends PacketTranslator<ClientboundEntit
|
|||
break;
|
||||
case LIVING_DEATH:
|
||||
entityEventPacket.setType(EntityEventType.DEATH);
|
||||
if (entity.getDefinition() == EntityDefinitions.THROWN_EGG) {
|
||||
if (entity.getDefinition() == EntityDefinitions.EGG) {
|
||||
LevelEventPacket particlePacket = new LevelEventPacket();
|
||||
particlePacket.setType(LevelEventType.PARTICLE_ITEM_BREAK);
|
||||
particlePacket.setData(session.getItemMappings().getStoredItems().egg().getBedrockId() << 16);
|
||||
|
|
|
@ -75,8 +75,8 @@ public final class EntityUtils {
|
|||
case CHICKEN, SPIDER -> mountedHeightOffset = height * 0.5f;
|
||||
case DONKEY, MULE -> mountedHeightOffset -= 0.25f;
|
||||
case LLAMA -> mountedHeightOffset = height * 0.67f;
|
||||
case MINECART, MINECART_HOPPER, MINECART_TNT, MINECART_CHEST, MINECART_FURNACE, MINECART_SPAWNER,
|
||||
MINECART_COMMAND_BLOCK -> mountedHeightOffset = 0;
|
||||
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
|
||||
COMMAND_BLOCK_MINECART -> mountedHeightOffset = 0;
|
||||
case BOAT -> mountedHeightOffset = -0.1f;
|
||||
case HOGLIN, ZOGLIN -> {
|
||||
boolean isBaby = mount.getFlag(EntityFlag.BABY);
|
||||
|
@ -169,8 +169,8 @@ public final class EntityUtils {
|
|||
yOffset += EntityDefinitions.PLAYER.offset();
|
||||
}
|
||||
switch (mount.getDefinition().entityType()) {
|
||||
case MINECART, MINECART_HOPPER, MINECART_TNT, MINECART_CHEST, MINECART_FURNACE, MINECART_SPAWNER,
|
||||
MINECART_COMMAND_BLOCK, BOAT -> yOffset -= mount.getDefinition().height() * 0.5f;
|
||||
case MINECART, HOPPER_MINECART, TNT_MINECART, CHEST_MINECART, FURNACE_MINECART, SPAWNER_MINECART,
|
||||
COMMAND_BLOCK_MINECART, BOAT -> yOffset -= mount.getDefinition().height() * 0.5f;
|
||||
}
|
||||
Vector3f offset = Vector3f.from(xOffset, yOffset, zOffset);
|
||||
passenger.setRiderSeatPosition(offset);
|
||||
|
|
Loading…
Reference in a new issue