Initial work on 1.13 entity metadata (#4539)
* Initial work on 1.13 entity metadata * Largely complete metadata Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
parent
ff2c246de2
commit
eb0f640fa0
@ -34,6 +34,7 @@ cBoat::cBoat(Vector3d a_Pos, eMaterial a_Material) :
|
||||
void cBoat::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnEntity(*this);
|
||||
a_ClientHandle.SendEntityMetadata(*this); // Boat colour
|
||||
}
|
||||
|
||||
|
||||
@ -154,9 +155,6 @@ void cBoat::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
|
||||
{
|
||||
SetLastDamage(GetLastDamage() - 1);
|
||||
}
|
||||
|
||||
// Broadcast any changes in position
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -183,6 +181,9 @@ void cBoat::HandleSpeedFromAttachee(float a_Forward, float a_Sideways)
|
||||
void cBoat::SetLastDamage(int TimeSinceLastHit)
|
||||
{
|
||||
m_LastDamage = TimeSinceLastHit;
|
||||
|
||||
// Tell the client to play the shaking animation
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
||||
@ -191,10 +192,16 @@ void cBoat::SetLastDamage(int TimeSinceLastHit)
|
||||
|
||||
void cBoat::UpdatePaddles(bool a_RightPaddleUsed, bool a_LeftPaddleUsed)
|
||||
{
|
||||
// Avoid telling client what it already knows since it may reset animation 1.13+
|
||||
const bool Changed = (m_RightPaddleUsed != a_RightPaddleUsed) || (m_LeftPaddleUsed != a_LeftPaddleUsed);
|
||||
|
||||
m_RightPaddleUsed = a_RightPaddleUsed;
|
||||
m_LeftPaddleUsed = a_LeftPaddleUsed;
|
||||
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
if (Changed)
|
||||
{
|
||||
m_World->BroadcastEntityMetadata(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,6 +145,193 @@ public:
|
||||
pktWindowProperty
|
||||
};
|
||||
|
||||
enum class eEntityMetadata
|
||||
{
|
||||
EntityFlags,
|
||||
EntityAir,
|
||||
EntityCustomName,
|
||||
EntityCustomNameVisible,
|
||||
EntitySilent,
|
||||
EntityNoGravity,
|
||||
EntityPose,
|
||||
|
||||
PotionThrown,
|
||||
|
||||
FallingBlockPosition,
|
||||
|
||||
AreaEffectCloudRadius,
|
||||
AreaEffectCloudColor,
|
||||
AreaEffectCloudSinglePointEffect,
|
||||
AreaEffectCloudParticleId,
|
||||
AreaEffectCloudParticleParameter1,
|
||||
AreaEffectCloudParticleParameter2,
|
||||
|
||||
ArrowFlags,
|
||||
TippedArrowColor,
|
||||
|
||||
BoatLastHitTime,
|
||||
BoatForwardDirection,
|
||||
BoatDamageTaken,
|
||||
BoatType,
|
||||
BoatLeftPaddleTurning,
|
||||
BoatRightPaddleTurning,
|
||||
BoatSplashTimer,
|
||||
|
||||
EnderCrystalBeamTarget,
|
||||
EnderCrystalShowBottom,
|
||||
|
||||
WitherSkullInvulnerable,
|
||||
|
||||
FireworkInfo,
|
||||
FireworkBoostedEntityId,
|
||||
|
||||
ItemFrameItem,
|
||||
ItemFrameRotation,
|
||||
|
||||
ItemItem,
|
||||
|
||||
LivingActiveHand,
|
||||
LivingHealth,
|
||||
LivingPotionEffectColor,
|
||||
LivingPotionEffectAmbient,
|
||||
LivingNumberOfArrows,
|
||||
|
||||
PlayerAdditionalHearts,
|
||||
PlayerScore,
|
||||
PlayerDisplayedSkinParts,
|
||||
PlayerMainHand,
|
||||
|
||||
ArmorStandStatus,
|
||||
ArmorStandHeadRotation,
|
||||
ArmorStandBodyRotation,
|
||||
ArmorStandLeftArmRotation,
|
||||
ArmorStandRightArmRotation,
|
||||
ArmorStandLeftLegRotation,
|
||||
ArmorStandRightLegRotation,
|
||||
|
||||
InsentientFlags,
|
||||
|
||||
BatHanging,
|
||||
|
||||
AgeableIsBaby,
|
||||
|
||||
AbstractHorseFlags,
|
||||
AbstractHorseOwner,
|
||||
|
||||
HorseVariant,
|
||||
HorseArmour,
|
||||
|
||||
ChestedHorseChested,
|
||||
|
||||
LlamaStrength,
|
||||
LlamaCarpetColor,
|
||||
LlamaVariant,
|
||||
|
||||
PigHasSaddle,
|
||||
PigTotalCarrotOnAStickBoost,
|
||||
|
||||
RabbitType,
|
||||
|
||||
PolarBearStanding,
|
||||
|
||||
SheepFlags,
|
||||
|
||||
TameableAnimalFlags,
|
||||
TameableAnimalOwner,
|
||||
|
||||
OcelotType,
|
||||
|
||||
WolfDamageTaken,
|
||||
WolfBegging,
|
||||
WolfCollarColour,
|
||||
|
||||
VillagerProfession,
|
||||
|
||||
IronGolemPlayerCreated,
|
||||
|
||||
ShulkerFacingDirection,
|
||||
ShulkerAttachmentFallingBlockPosition,
|
||||
ShulkerShieldHeight,
|
||||
|
||||
BlazeOnFire,
|
||||
|
||||
CreeperState,
|
||||
CreeperPowered,
|
||||
CreeperIgnited,
|
||||
|
||||
GuardianStatus,
|
||||
GuardianTarget,
|
||||
|
||||
IllagerFlags,
|
||||
SpeIlagerSpell,
|
||||
|
||||
VexFlags,
|
||||
|
||||
AbstractSkeletonArmsSwinging,
|
||||
|
||||
SpiderClimbing,
|
||||
|
||||
WitchAggresive,
|
||||
|
||||
WitherFirstHeadTarget,
|
||||
WitherSecondHeadTarget,
|
||||
WitherThirdHeadTarget,
|
||||
WitherInvulnerableTimer,
|
||||
|
||||
ZombieIsBaby,
|
||||
ZombieUnusedWasType,
|
||||
ZombieHandsRisedUp,
|
||||
|
||||
ZombieVillagerConverting,
|
||||
ZombieVillagerProfession,
|
||||
|
||||
EndermanCarriedBlock,
|
||||
EndermanScreaming,
|
||||
|
||||
EnderDragonDragonPhase,
|
||||
|
||||
GhastAttacking,
|
||||
|
||||
SlimeSize,
|
||||
|
||||
MinecartShakingPower,
|
||||
MinecartShakingDirection,
|
||||
MinecartShakingMultiplier,
|
||||
MinecartBlockIDMeta,
|
||||
MinecartBlockY,
|
||||
MinecartShowBlock,
|
||||
|
||||
MinecartCommandBlockCommand,
|
||||
MinecartCommandBlockLastOutput,
|
||||
|
||||
MinecartFurnacePowered,
|
||||
|
||||
TNTPrimedFuseTime
|
||||
};
|
||||
|
||||
enum class eEntityMetadataType
|
||||
{
|
||||
Byte,
|
||||
VarInt,
|
||||
Float,
|
||||
String,
|
||||
Chat,
|
||||
OptChat,
|
||||
Item,
|
||||
Boolean,
|
||||
Rotation,
|
||||
Position,
|
||||
OptPosition,
|
||||
Direction,
|
||||
OptUUID,
|
||||
OptBlockID,
|
||||
NBT,
|
||||
Particle,
|
||||
VillagerData,
|
||||
OptVarInt,
|
||||
Pose
|
||||
};
|
||||
|
||||
/** Called when client sends some data */
|
||||
virtual void DataReceived(const char * a_Data, size_t a_Size) = 0;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,45 +39,51 @@ public:
|
||||
|
||||
virtual void Initialize(cClientHandle & a_Client) override;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** The palette used to transform internal block type palette into the protocol-specific ID. */
|
||||
std::shared_ptr<const BlockTypePalette> m_BlockTypePalette;
|
||||
|
||||
/** Temporary hack for initial 1.13+ support while keeping BLOCKTYPE data:
|
||||
Map of the BLOCKTYPE#META to the protocol-specific NetBlockID. */
|
||||
std::map<UInt32, UInt32> m_BlockTypeMap;
|
||||
|
||||
|
||||
/** Returns the string identifying the palettes' version, such as "1.13" or "1.14.4".
|
||||
The palettes for that version are loaded into m_BlockTypePalette and m_ItemTypePalette. */
|
||||
virtual AString GetPaletteVersion() const;
|
||||
|
||||
// Outgoing packet type translation:
|
||||
virtual UInt32 GetPacketID(ePacketType a_PacketType) override;
|
||||
|
||||
// Packet receiving:
|
||||
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
|
||||
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
||||
virtual void HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) override;
|
||||
|
||||
// Packet sending:
|
||||
virtual void SendBlockChange (int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
|
||||
virtual void SendBlockChanges (int a_ChunkX, int a_ChunkZ, const sSetBlockVector & a_Changes) override;
|
||||
virtual void SendChunkData (int a_ChunkX, int a_ChunkZ, cChunkDataSerializer & a_Serializer) override;
|
||||
virtual void SendMapData (const cMap & a_Map, int a_DataStartX, int a_DataStartY) override;
|
||||
virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
|
||||
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
|
||||
virtual void SendPluginMessage (const AString & a_Channel, const AString & a_Message) override;
|
||||
virtual void SendScoreboardObjective (const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) override;
|
||||
virtual void SendStatistics (const cStatManager & a_Manager) override;
|
||||
virtual void SendTabCompletionResults (const AStringVector & a_Results) override;
|
||||
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override;
|
||||
|
||||
// Packet receiving:
|
||||
virtual bool HandlePacket(cByteBuffer & a_ByteBuffer, UInt32 a_PacketType) override;
|
||||
virtual void HandlePacketStatusRequest(cByteBuffer & a_ByteBuffer) override;
|
||||
virtual void HandlePacketPluginMessage(cByteBuffer & a_ByteBuffer) override;
|
||||
|
||||
// Outgoing packet type translation:
|
||||
virtual UInt32 GetPacketID(ePacketType a_PacketType) override;
|
||||
|
||||
/** Converts eMonsterType to protocol-specific mob types */
|
||||
virtual UInt32 GetProtocolMobType(eMonsterType a_MobType) override;
|
||||
|
||||
virtual UInt8 GetEntityMetadataID(eEntityMetadata a_Metadata);
|
||||
virtual UInt8 GetEntityMetadataID(eEntityMetadataType a_FieldType);
|
||||
|
||||
virtual bool ReadItem(cByteBuffer & a_ByteBuffer, cItem & a_Item, size_t a_KeepRemainingBytes) override;
|
||||
virtual void WriteItem(cPacketizer & a_Pkt, const cItem & a_Item) override;
|
||||
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const eEntityMetadata a_Metadata, const eEntityMetadataType a_FieldType);
|
||||
virtual void WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a_Entity) override;
|
||||
virtual void WriteMobMetadata(cPacketizer & a_Pkt, const cMonster & a_Mob) override;
|
||||
|
||||
private:
|
||||
|
||||
/** The palette used to transform internal block type palette into the protocol-specific ID. */
|
||||
std::shared_ptr<const BlockTypePalette> m_BlockTypePalette;
|
||||
|
||||
/** Temporary hack for initial 1.13+ support while keeping BLOCKTYPE data:
|
||||
Map of the BLOCKTYPE#META to the protocol-specific NetBlockID. */
|
||||
std::map<UInt32, UInt32> m_BlockTypeMap;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user