Skip to content

Commit

Permalink
Fix LegacyTelemetryEventPacket (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 authored Aug 19, 2024
2 parents aebbc70 + 97b2016 commit b00c443
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected EntityInteractEventData readEntityInteract(ByteBuf buffer, BedrockCode
int interactionEntityType = VarInts.readInt(buffer);
int entityVariant = VarInts.readInt(buffer);
int entityColor = buffer.readUnsignedByte();
return new EntityInteractEventData(interactionType, interactionEntityType, entityVariant, entityColor);
return new EntityInteractEventData(-1L, interactionType, interactionEntityType, entityVariant, entityColor);
}

protected void writeEntityInteract(ByteBuf buffer, BedrockCodecHelper helper, EventData eventData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ protected EventSerializer_v471() {
this.writers.put(EventDataType.COPPER_WAXED_OR_UNWAXED, this::writeCopperWaxedUnwaxed);
this.readers.put(EventDataType.CODE_BUILDER_ACTION, this::readCodeBuilderAction);
this.writers.put(EventDataType.CODE_BUILDER_ACTION, this::writeCodeBuilderAction);
this.readers.put(EventDataType.CODE_BUILDER_SCOREBOARD, this::readCodeBuilderScoreboard);
this.writers.put(EventDataType.CODE_BUILDER_SCOREBOARD, this::writeCodeBuilderScoreboard);
this.readers.put(EventDataType.STRIDER_RIDDEN_IN_LAVA_IN_OVERWORLD, (b, h) -> StriderRiddenInLavaInOverworldEventData.INSTANCE);
this.writers.put(EventDataType.STRIDER_RIDDEN_IN_LAVA_IN_OVERWORLD, (b, h, e) -> {});
this.readers.put(EventDataType.SNEAK_CLOSE_TO_SCULK_SENSOR, (b, h) -> SneakCloseToSculkSensorEventData.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class Bedrock_v671 extends Bedrock_v662 {
.updateSerializer(UpdatePlayerGameTypePacket.class, UpdatePlayerGameTypeSerializer_v671.INSTANCE)
.updateSerializer(StartGamePacket.class, StartGameSerializer_v671.INSTANCE)
.updateSerializer(CraftingDataPacket.class, CraftingDataSerializer_v671.INSTANCE)
.deregisterPacket(FilterTextPacket.class) // TODO: check
// TODO: confirm change in AnimatePacket
.updateSerializer(EventPacket.class, EventSerializer_v671.INSTANCE)
.deregisterPacket(FilterTextPacket.class)
.build();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.cloudburstmc.protocol.bedrock.codec.v671.serializer;

import io.netty.buffer.ByteBuf;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
import org.cloudburstmc.protocol.bedrock.codec.v589.serializer.EventSerializer_v589;
import org.cloudburstmc.protocol.bedrock.data.event.EntityInteractEventData;
import org.cloudburstmc.protocol.bedrock.data.event.EventData;
import org.cloudburstmc.protocol.common.util.VarInts;

public class EventSerializer_v671 extends EventSerializer_v589 {
public static final EventSerializer_v671 INSTANCE = new EventSerializer_v671();

@Override
protected EntityInteractEventData readEntityInteract(ByteBuf buffer, BedrockCodecHelper helper) {
long interactedEntityID = VarInts.readLong(buffer);
int interactionType = VarInts.readInt(buffer);
int interactionEntityType = VarInts.readInt(buffer);
int entityVariant = VarInts.readInt(buffer);
int entityColor = buffer.readUnsignedByte();
return new EntityInteractEventData(interactedEntityID, interactionType, interactionEntityType, entityVariant, entityColor);
}

@Override
protected void writeEntityInteract(ByteBuf buffer, BedrockCodecHelper helper, EventData eventData) {
EntityInteractEventData event = (EntityInteractEventData) eventData;
VarInts.writeLong(buffer, event.getInteractedEntityID());
VarInts.writeInt(buffer, event.getInteractionType());
VarInts.writeInt(buffer, event.getLegacyEntityTypeId());
VarInts.writeInt(buffer, event.getVariant());
buffer.writeByte(event.getPaletteColor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import io.netty.buffer.ByteBuf;
import org.cloudburstmc.protocol.bedrock.codec.BedrockCodecHelper;
import org.cloudburstmc.protocol.bedrock.codec.v589.serializer.EventSerializer_v589;
import org.cloudburstmc.protocol.bedrock.codec.v671.serializer.EventSerializer_v671;
import org.cloudburstmc.protocol.bedrock.data.event.EventData;
import org.cloudburstmc.protocol.bedrock.data.event.EventDataType;
import org.cloudburstmc.protocol.bedrock.data.event.ItemUsedEventData;

public class EventSerializer_v685 extends EventSerializer_v589 {
public class EventSerializer_v685 extends EventSerializer_v671 {
public static final EventSerializer_v685 INSTANCE = new EventSerializer_v685();

public EventSerializer_v685() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

@Value
public class EntityInteractEventData implements EventData {
/**
* @since v671
*/
private final long interactedEntityID;
private final int interactionType;
private final int legacyEntityTypeId;
private final int variant;
Expand Down

0 comments on commit b00c443

Please sign in to comment.