Skip to content

Commit bbb490e

Browse files
committed
✨ add more Clientbound packets 2 -- still untested
1 parent 6f25aa0 commit bbb490e

14 files changed

+541
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.core.Registry;
5+
import net.minecraft.core.registries.BuiltInRegistries;
6+
import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket;
7+
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
8+
import net.minecraft.world.level.block.entity.BlockEntityType;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
12+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
13+
import xyz.bitsquidd.ninja.handler.PacketHandler;
14+
import xyz.bitsquidd.ninja.handler.PacketType;
15+
16+
import java.util.List;
17+
import java.util.Objects;
18+
19+
public class BlockEntityDataHandler extends PacketHandler<@NotNull ClientboundBlockEntityDataPacket> {
20+
21+
public BlockEntityDataHandler() {
22+
super(
23+
ClientboundBlockEntityDataPacket.class,
24+
"BlockEntityData",
25+
"Handles ClientboundBlockEntityDataPacket.",
26+
PacketType.CLIENTBOUND
27+
);
28+
}
29+
30+
@Override
31+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockEntityDataPacket packet) {
32+
return PacketInfoBundle.of(
33+
packetType,
34+
Component.text(friendlyName),
35+
List.of(
36+
PacketInfoSegment.of(Component.text("Position"), Component.text(packet.getPos().getX() + ", " + packet.getPos().getY() + ", " + packet.getPos().getZ())),
37+
PacketInfoSegment.of(Component.text("Type"), Component.text(Objects.requireNonNullElse(BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(packet.getType()), "Unknown").toString())),
38+
PacketInfoSegment.of(Component.text("Tag"), Component.text(packet.getTag().toString()))
39+
)
40+
);
41+
}
42+
43+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.core.registries.BuiltInRegistries;
5+
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
6+
import net.minecraft.network.protocol.game.ClientboundBlockEventPacket;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
10+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
11+
import xyz.bitsquidd.ninja.handler.PacketHandler;
12+
import xyz.bitsquidd.ninja.handler.PacketType;
13+
14+
import java.util.List;
15+
import java.util.Objects;
16+
17+
public class BlockEventHandler extends PacketHandler<@NotNull ClientboundBlockEventPacket> {
18+
19+
public BlockEventHandler() {
20+
super(
21+
ClientboundBlockEventPacket.class,
22+
"BlockEvent",
23+
"Handles ClientboundBlockDestructionPacket.",
24+
PacketType.CLIENTBOUND
25+
);
26+
}
27+
28+
@Override
29+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockEventPacket packet) {
30+
return PacketInfoBundle.of(
31+
packetType,
32+
Component.text(friendlyName),
33+
List.of(
34+
PacketInfoSegment.of(Component.text("Position"), Component.text(packet.getPos().getX() + ", " + packet.getPos().getY() + ", " + packet.getPos().getZ())),
35+
PacketInfoSegment.of(Component.text("Friction"), Component.text(packet.getBlock().getFriction())),
36+
PacketInfoSegment.of(Component.text("ExplosionResistance"), Component.text(packet.getBlock().getExplosionResistance())),
37+
PacketInfoSegment.of(Component.text("JumpFactor"), Component.text(packet.getBlock().getJumpFactor())),
38+
PacketInfoSegment.of(Component.text("SpeedFactor"), Component.text(packet.getBlock().getSpeedFactor())),
39+
PacketInfoSegment.of(Component.text("B0"), Component.text(packet.getB0())),
40+
PacketInfoSegment.of(Component.text("B1"), Component.text(packet.getB1()))
41+
)
42+
);
43+
}
44+
45+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundBlockEventPacket;
5+
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
9+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
10+
import xyz.bitsquidd.ninja.handler.PacketHandler;
11+
import xyz.bitsquidd.ninja.handler.PacketType;
12+
13+
import java.util.List;
14+
15+
public class BlockUpdateHandler extends PacketHandler<@NotNull ClientboundBlockUpdatePacket> {
16+
17+
public BlockUpdateHandler() {
18+
super(
19+
ClientboundBlockUpdatePacket.class,
20+
"BlockUpdate",
21+
"Handles ClientboundBlockUpdatePacket.",
22+
PacketType.CLIENTBOUND
23+
);
24+
}
25+
26+
@Override
27+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockUpdatePacket packet) {
28+
return PacketInfoBundle.of(
29+
packetType,
30+
Component.text(friendlyName),
31+
List.of(
32+
PacketInfoSegment.of(Component.text("Position"), Component.text(packet.getPos().getX() + ", " + packet.getPos().getY() + ", " + packet.getPos().getZ())),
33+
PacketInfoSegment.of(Component.text("BlockState"), Component.text(packet.getBlockState().toString()))
34+
)
35+
);
36+
}
37+
38+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
5+
import net.minecraft.network.protocol.game.ClientboundBossEventPacket;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
9+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
10+
import xyz.bitsquidd.ninja.handler.PacketHandler;
11+
import xyz.bitsquidd.ninja.handler.PacketType;
12+
13+
import java.util.List;
14+
15+
public class BossEventHandler extends PacketHandler<@NotNull ClientboundBossEventPacket> {
16+
17+
public BossEventHandler() {
18+
super(
19+
ClientboundBossEventPacket.class,
20+
"BossEvent",
21+
"Handles ClientboundBossEventPacket.",
22+
PacketType.CLIENTBOUND
23+
);
24+
}
25+
26+
@Override
27+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBossEventPacket packet) {
28+
return PacketInfoBundle.of(
29+
packetType,
30+
Component.text(friendlyName),
31+
List.of()
32+
);
33+
}
34+
35+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundBundleDelimiterPacket;
5+
import org.jetbrains.annotations.NotNull;
6+
7+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
8+
import xyz.bitsquidd.ninja.handler.PacketHandler;
9+
import xyz.bitsquidd.ninja.handler.PacketType;
10+
11+
import java.util.List;
12+
13+
public class BundleDelimiterHandler extends PacketHandler<@NotNull ClientboundBundleDelimiterPacket> {
14+
15+
public BundleDelimiterHandler() {
16+
super(
17+
ClientboundBundleDelimiterPacket.class,
18+
"BundleDelimiter",
19+
"Handles ClientboundBundleDelimiterPacket.",
20+
PacketType.CLIENTBOUND
21+
);
22+
}
23+
24+
@Override
25+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBundleDelimiterPacket packet) {
26+
return PacketInfoBundle.of(
27+
packetType,
28+
Component.text(friendlyName),
29+
List.of()
30+
);
31+
}
32+
33+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundBundleDelimiterPacket;
5+
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
9+
import xyz.bitsquidd.ninja.handler.PacketHandler;
10+
import xyz.bitsquidd.ninja.handler.PacketType;
11+
12+
import java.util.List;
13+
14+
public class BundleHandler extends PacketHandler<@NotNull ClientboundBundlePacket> {
15+
16+
public BundleHandler() {
17+
super(
18+
ClientboundBundlePacket.class,
19+
"Bundle",
20+
"Handles ClientboundBundlePacket.",
21+
PacketType.CLIENTBOUND
22+
);
23+
}
24+
25+
@Override
26+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBundlePacket packet) {
27+
return PacketInfoBundle.of(
28+
packetType,
29+
Component.text(friendlyName),
30+
List.of()
31+
);
32+
}
33+
34+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
5+
import net.minecraft.network.protocol.game.ClientboundChangeDifficultyPacket;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
9+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
10+
import xyz.bitsquidd.ninja.handler.PacketHandler;
11+
import xyz.bitsquidd.ninja.handler.PacketType;
12+
13+
import java.util.List;
14+
15+
public class ChangeDifficultyHandler extends PacketHandler<@NotNull ClientboundChangeDifficultyPacket> {
16+
17+
public ChangeDifficultyHandler() {
18+
super(
19+
ClientboundChangeDifficultyPacket.class,
20+
"ChangeDifficulty",
21+
"Handles ClientboundChangeDifficultyPacket.",
22+
PacketType.CLIENTBOUND
23+
);
24+
}
25+
26+
@Override
27+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundChangeDifficultyPacket packet) {
28+
return PacketInfoBundle.of(
29+
packetType,
30+
Component.text(friendlyName),
31+
List.of(
32+
PacketInfoSegment.of(Component.text("Difficulty"), Component.text(packet.difficulty().name())),
33+
PacketInfoSegment.of(Component.text("Locked"), Component.text(packet.locked()))
34+
)
35+
);
36+
}
37+
38+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundChangeDifficultyPacket;
5+
import net.minecraft.network.protocol.game.ClientboundChunkBatchFinishedPacket;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
9+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
10+
import xyz.bitsquidd.ninja.handler.PacketHandler;
11+
import xyz.bitsquidd.ninja.handler.PacketType;
12+
13+
import java.util.List;
14+
15+
public class ChunkBatchFinishedHandler extends PacketHandler<@NotNull ClientboundChunkBatchFinishedPacket> {
16+
17+
public ChunkBatchFinishedHandler() {
18+
super(
19+
ClientboundChunkBatchFinishedPacket.class,
20+
"ChunkBatchFinished",
21+
"Handles ClientboundChunkBatchFinishedPacket.",
22+
PacketType.CLIENTBOUND
23+
);
24+
}
25+
26+
@Override
27+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundChunkBatchFinishedPacket packet) {
28+
return PacketInfoBundle.of(
29+
packetType,
30+
Component.text(friendlyName),
31+
List.of(
32+
PacketInfoSegment.of(Component.text("BatchSize"), Component.text(packet.batchSize()))
33+
)
34+
);
35+
}
36+
37+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundChunkBatchFinishedPacket;
5+
import net.minecraft.network.protocol.game.ClientboundChunkBatchStartPacket;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
9+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
10+
import xyz.bitsquidd.ninja.handler.PacketHandler;
11+
import xyz.bitsquidd.ninja.handler.PacketType;
12+
13+
import java.util.List;
14+
15+
public class ChunkBatchStartHandler extends PacketHandler<@NotNull ClientboundChunkBatchStartPacket> {
16+
17+
public ChunkBatchStartHandler() {
18+
super(
19+
ClientboundChunkBatchStartPacket.class,
20+
"ChunkBatchStart",
21+
"Handles ClientboundChunkBatchStartPacket.",
22+
PacketType.CLIENTBOUND
23+
);
24+
}
25+
26+
@Override
27+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundChunkBatchStartPacket packet) {
28+
return PacketInfoBundle.of(
29+
packetType,
30+
Component.text(friendlyName),
31+
List.of()
32+
);
33+
}
34+
35+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package xyz.bitsquidd.ninja.handler.impl.clientbound;
2+
3+
import net.kyori.adventure.text.Component;
4+
import net.minecraft.network.protocol.game.ClientboundChunkBatchFinishedPacket;
5+
import net.minecraft.network.protocol.game.ClientboundChunksBiomesPacket;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import xyz.bitsquidd.ninja.format.FormatHelper;
9+
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
10+
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
11+
import xyz.bitsquidd.ninja.handler.PacketHandler;
12+
import xyz.bitsquidd.ninja.handler.PacketType;
13+
14+
import java.util.List;
15+
16+
public class ChunksBiomesHandler extends PacketHandler<@NotNull ClientboundChunksBiomesPacket> {
17+
18+
public ChunksBiomesHandler() {
19+
super(
20+
ClientboundChunksBiomesPacket.class,
21+
"ChunksBiomes",
22+
"Handles ClientboundChunksBiomesPacket.",
23+
PacketType.CLIENTBOUND
24+
);
25+
}
26+
27+
@Override
28+
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundChunksBiomesPacket packet) {
29+
String chunkBiomeDataList = FormatHelper.formatList(packet.chunkBiomeData().stream().toList(), MAX_DISPLAYED_ENTRIES);
30+
31+
return PacketInfoBundle.of(
32+
packetType,
33+
Component.text(friendlyName),
34+
List.of(
35+
PacketInfoSegment.of(Component.text("BatchSize"), Component.text(chunkBiomeDataList))
36+
)
37+
);
38+
}
39+
40+
}

0 commit comments

Comments
 (0)