Skip to content

Commit ee72557

Browse files
committed
Add telemetry events missed in 1.13 and 1.14
1 parent f9705b6 commit ee72557

File tree

10 files changed

+462
-4
lines changed

10 files changed

+462
-4
lines changed

bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/annotation/NoEncryption.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import java.lang.annotation.RetentionPolicy;
66
import java.lang.annotation.Target;
77

8+
/**
9+
* Packets with this annotation will be sent in plain text over the network
10+
*
11+
* @see com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket
12+
*/
813
@Retention(RetentionPolicy.RUNTIME)
914
@Target(ElementType.TYPE)
1015
public @interface NoEncryption {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.nukkitx.protocol.bedrock.data.event;
2+
3+
import lombok.Value;
4+
5+
@Value
6+
public class EntityDefinitionTriggerEventData implements EventData {
7+
private final String id;
8+
9+
@Override
10+
public EventDataType getType() {
11+
return EventDataType.ENTITY_DEFINITION_TRIGGER;
12+
}
13+
}

bedrock/bedrock-common/src/main/java/com/nukkitx/protocol/bedrock/data/event/EventDataType.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,10 @@ public enum EventDataType {
1818
PET_DIED,
1919
CAULDRON_BLOCK_USED,
2020
COMPOSTER_BLOCK_USED,
21-
BELL_BLOCK_USED
21+
BELL_BLOCK_USED,
22+
ENTITY_DEFINITION_TRIGGER, // 18
23+
RAID_UPDATE, // 19
24+
MOVEMENT, // 20
25+
MOVEMENT_THRESHOLD, // 21
26+
EXTRACT_HONEY // 22
2227
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.nukkitx.protocol.bedrock.data.event;
2+
3+
import lombok.AccessLevel;
4+
import lombok.NoArgsConstructor;
5+
6+
@NoArgsConstructor(access = AccessLevel.PRIVATE)
7+
public class ExtractHoneyEventData implements EventData {
8+
public static final ExtractHoneyEventData INSTANCE = new ExtractHoneyEventData();
9+
10+
@Override
11+
public EventDataType getType() {
12+
return EventDataType.EXTRACT_HONEY;
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.nukkitx.protocol.bedrock.data.event;
2+
3+
import com.nukkitx.math.vector.Vector2f;
4+
import com.nukkitx.math.vector.Vector3f;
5+
import lombok.Value;
6+
7+
@Value
8+
public class MovementEventData implements EventData {
9+
private final int movementType;
10+
private final Vector2f rotation; // Guess
11+
private final Vector3f position; // Guess
12+
13+
@Override
14+
public EventDataType getType() {
15+
return EventDataType.MOVEMENT;
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.nukkitx.protocol.bedrock.data.event;
2+
3+
import lombok.Value;
4+
5+
@Value
6+
public class MovementThresholdEventData implements EventData {
7+
private final float unknown0;
8+
private final float unknown1;
9+
private final float playerMovementScoreThreshold;
10+
private final float playerMovementDistanceThreshold;
11+
private final int playerMovementDurationThreshold;
12+
13+
@Override
14+
public EventDataType getType() {
15+
return EventDataType.MOVEMENT_THRESHOLD;
16+
}
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.nukkitx.protocol.bedrock.data.event;
2+
3+
import lombok.Value;
4+
5+
@Value
6+
public class RaidUpdateEventData implements EventData {
7+
private final int currentWave;
8+
private final int totalWaves;
9+
private final boolean unknown0; // Hero of the village?
10+
11+
@Override
12+
public EventDataType getType() {
13+
return EventDataType.RAID_UPDATE;
14+
}
15+
}

bedrock/bedrock-v388/src/main/java/com/nukkitx/protocol/bedrock/v388/serializer/EventSerializer_v388.java

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.nukkitx.protocol.bedrock.v388.serializer;
22

3+
import com.nukkitx.math.vector.Vector2f;
4+
import com.nukkitx.math.vector.Vector3f;
35
import com.nukkitx.network.VarInts;
46
import com.nukkitx.network.util.Preconditions;
57
import com.nukkitx.protocol.bedrock.data.event.*;
@@ -80,6 +82,9 @@ public void serialize(ByteBuf buffer, EventPacket packet) {
8082
BedrockUtils.writeString(buffer, agentCommandEventData.getDataKey());
8183
BedrockUtils.writeString(buffer, agentCommandEventData.getOutput());
8284
break;
85+
case AGENT_CREATED:
86+
// No extra data
87+
break;
8388
case PATTERN_REMOVED:
8489
PatternRemovedEventData patternRemovedEventData = (PatternRemovedEventData) eventData;
8590
VarInts.writeInt(buffer, patternRemovedEventData.getItemId());
@@ -130,8 +135,28 @@ public void serialize(ByteBuf buffer, EventPacket packet) {
130135
case BELL_BLOCK_USED:
131136
VarInts.writeInt(buffer, ((BellBlockUsedEventData) eventData).getUnknown0());
132137
break;
133-
case AGENT_CREATED:
134-
// No extra data
138+
case ENTITY_DEFINITION_TRIGGER:
139+
BedrockUtils.writeString(buffer, ((EntityDefinitionTriggerEventData) eventData).getId());
140+
break;
141+
case RAID_UPDATE:
142+
RaidUpdateEventData raidUpdateEventData = (RaidUpdateEventData) eventData;
143+
VarInts.writeInt(buffer, raidUpdateEventData.getCurrentWave());
144+
VarInts.writeInt(buffer, raidUpdateEventData.getTotalWaves());
145+
buffer.writeBoolean(raidUpdateEventData.isUnknown0());
146+
break;
147+
case MOVEMENT:
148+
MovementEventData movementEventData = (MovementEventData) eventData;
149+
buffer.writeByte(movementEventData.getMovementType());
150+
BedrockUtils.writeVector2f(buffer, movementEventData.getRotation());
151+
BedrockUtils.writeVector3f(buffer, movementEventData.getPosition());
152+
break;
153+
case MOVEMENT_THRESHOLD:
154+
MovementThresholdEventData movementThresholdEventData = (MovementThresholdEventData) eventData;
155+
buffer.writeFloatLE(movementThresholdEventData.getUnknown0());
156+
buffer.writeFloatLE(movementThresholdEventData.getUnknown1());
157+
buffer.writeFloatLE(movementThresholdEventData.getPlayerMovementScoreThreshold());
158+
buffer.writeFloatLE(movementThresholdEventData.getPlayerMovementDistanceThreshold());
159+
VarInts.writeInt(buffer, movementThresholdEventData.getPlayerMovementDurationThreshold());
135160
break;
136161
}
137162
}
@@ -256,6 +281,31 @@ public void deserialize(ByteBuf buffer, EventPacket packet) {
256281
case BELL_BLOCK_USED:
257282
data = new BellBlockUsedEventData(VarInts.readInt(buffer));
258283
break;
284+
case ENTITY_DEFINITION_TRIGGER:
285+
String id = BedrockUtils.readString(buffer);
286+
data = new EntityDefinitionTriggerEventData(id);
287+
break;
288+
case RAID_UPDATE:
289+
int currentWave = VarInts.readInt(buffer);
290+
int totalWaves = VarInts.readInt(buffer);
291+
unknownBool = buffer.readBoolean();
292+
data = new RaidUpdateEventData(currentWave, totalWaves, unknownBool);
293+
break;
294+
case MOVEMENT:
295+
int movementType = buffer.readUnsignedByte();
296+
Vector2f rotation = BedrockUtils.readVector2f(buffer);
297+
Vector3f position = BedrockUtils.readVector3f(buffer);
298+
data = new MovementEventData(movementType, rotation, position);
299+
break;
300+
case MOVEMENT_THRESHOLD:
301+
float unknownFloat0 = buffer.readFloatLE();
302+
float unknownFloat1 = buffer.readFloatLE();
303+
float playerMovementScoreThreshold = buffer.readFloatLE();
304+
float playerMovementDistanceThreshold = buffer.readFloatLE();
305+
int playerMovementDurationThreshold = VarInts.readInt(buffer);
306+
data = new MovementThresholdEventData(unknownFloat0, unknownFloat1, playerMovementScoreThreshold,
307+
playerMovementDistanceThreshold, playerMovementDurationThreshold);
308+
break;
259309
default:
260310
throw new IllegalArgumentException("Unknown EventDataType");
261311
}

bedrock/bedrock-v389/src/main/java/com/nukkitx/protocol/bedrock/v389/Bedrock_v389.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
44
import com.nukkitx.protocol.bedrock.packet.*;
55
import com.nukkitx.protocol.bedrock.v388.serializer.*;
6+
import com.nukkitx.protocol.bedrock.v389.serializer.EventSerializer_v389;
67
import lombok.experimental.UtilityClass;
78

89
@UtilityClass
@@ -74,7 +75,7 @@ public class Bedrock_v389 {
7475
.registerPacket(SetPlayerGameTypePacket.class, SetPlayerGameTypeSerializer_v388.INSTANCE, 62)
7576
.registerPacket(PlayerListPacket.class, PlayerListSerializer_v388.INSTANCE, 63)
7677
.registerPacket(SimpleEventPacket.class, SimpleEventSerializer_v388.INSTANCE, 64)
77-
.registerPacket(EventPacket.class, EventSerializer_v388.INSTANCE, 65)
78+
.registerPacket(EventPacket.class, EventSerializer_v389.INSTANCE, 65)
7879
.registerPacket(SpawnExperienceOrbPacket.class, SpawnExperienceOrbSerializer_v388.INSTANCE, 66)
7980
.registerPacket(ClientboundMapItemDataPacket.class, ClientboundMapItemDataSerializer_v388.INSTANCE, 67)
8081
.registerPacket(MapInfoRequestPacket.class, MapInfoRequestSerializer_v388.INSTANCE, 68)

0 commit comments

Comments
 (0)