-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from CoolLoong/3.0
fix: Missing PlayerDiedEventData serializer in v389
- Loading branch information
Showing
1 changed file
with
26 additions
and
2 deletions.
There are no files selected for viewing
28 changes: 26 additions & 2 deletions
28
...in/java/org/cloudburstmc/protocol/bedrock/codec/v389/serializer/EventSerializer_v389.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,40 @@ | ||
package org.cloudburstmc.protocol.bedrock.codec.v389.serializer; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper; | ||
import org.cloudburstmc.protocol.bedrock.codec.v388.serializer.EventSerializer_v388; | ||
import org.cloudburstmc.protocol.bedrock.data.event.EventData; | ||
import org.cloudburstmc.protocol.bedrock.data.event.EventDataType; | ||
import org.cloudburstmc.protocol.bedrock.data.event.ExtractHoneyEventData; | ||
import org.cloudburstmc.protocol.bedrock.data.event.PlayerDiedEventData; | ||
import org.cloudburstmc.protocol.common.util.VarInts; | ||
|
||
public class EventSerializer_v389 extends EventSerializer_v388 { | ||
public static final EventSerializer_v389 INSTANCE = new EventSerializer_v389(); | ||
|
||
protected EventSerializer_v389() { | ||
super(); | ||
this.readers.put(EventDataType.EXTRACT_HONEY, (b, h) -> ExtractHoneyEventData.INSTANCE); | ||
this.writers.put(EventDataType.EXTRACT_HONEY, (b, h, e) -> { | ||
}); | ||
this.writers.put(EventDataType.EXTRACT_HONEY, (b, h, e) -> {}); | ||
this.writers.put(EventDataType.PLAYER_DIED,this::writePlayerDied); | ||
this.readers.put(EventDataType.PLAYER_DIED,this::readPlayerDied); | ||
} | ||
|
||
@Override | ||
protected PlayerDiedEventData readPlayerDied(ByteBuf buffer, BedrockCodecHelper helper) { | ||
int attackerEntityId = VarInts.readInt(buffer); | ||
int attackerVariant = VarInts.readInt(buffer); | ||
int entityDamageCause = VarInts.readInt(buffer); | ||
boolean inRaid = buffer.readBoolean(); | ||
return new PlayerDiedEventData(attackerEntityId, attackerVariant, entityDamageCause, inRaid); | ||
} | ||
|
||
@Override | ||
protected void writePlayerDied(ByteBuf buffer, BedrockCodecHelper helper, EventData eventData) { | ||
PlayerDiedEventData event = (PlayerDiedEventData) eventData; | ||
VarInts.writeInt(buffer, event.getAttackerEntityId()); | ||
VarInts.writeInt(buffer, event.getAttackerVariant()); | ||
VarInts.writeInt(buffer, event.getEntityDamageCause()); | ||
buffer.writeBoolean(event.isInRaid()); | ||
} | ||
} |