Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundAnimatePacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;

public class AnimatePacketHandler extends PacketHandler<@NotNull ClientboundAnimatePacket> {

public AnimatePacketHandler() {
super(
ClientboundAnimatePacket.class,
"Animate",
"Handles ClientboundAnimatePacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundAnimatePacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of(
PacketInfoSegment.of(Component.text("Action"), Component.text(packet.getAction()))
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundAwardStatsPacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.FormatHelper;
import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;
import java.util.Map;

public class AwardStatsHandler extends PacketHandler<@NotNull ClientboundAwardStatsPacket> {

public AwardStatsHandler() {
super(
ClientboundAwardStatsPacket.class,
"AwardStats",
"Handles ClientboundAwardStatsPacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundAwardStatsPacket packet) {

String statsList = FormatHelper.formatList(
!packet.stats().isEmpty()
? packet.stats().object2IntEntrySet().stream()
.map(Map.Entry::getKey)
.toList()
: List.of(),
MAX_DISPLAYED_ENTRIES
);
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of(
PacketInfoSegment.of(Component.text("StatsCount"), Component.text(packet.stats().size())),
PacketInfoSegment.of(Component.text("Stats"), Component.text(statsList))
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundBlockChangedAckPacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;

public class BlockChangedAckHandler extends PacketHandler<@NotNull ClientboundBlockChangedAckPacket> {

public BlockChangedAckHandler() {
super(
ClientboundBlockChangedAckPacket.class,
"BlockChangedAck",
"Handles ClientboundBlockChangedAckPacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockChangedAckPacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of(
PacketInfoSegment.of(Component.text("Sequence"), Component.text(packet.sequence()))
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;

public class BlockDestructionHandler extends PacketHandler<@NotNull ClientboundBlockDestructionPacket> {

public BlockDestructionHandler() {
super(
ClientboundBlockDestructionPacket.class,
"BlockDestruction",
"Handles ClientboundBlockDestructionPacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockDestructionPacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of(
PacketInfoSegment.of(Component.text("Position"), Component.text(packet.getPos().getX() + ", " + packet.getPos().getY() + ", " + packet.getPos().getZ())),
PacketInfoSegment.of(Component.text("Progress"), Component.text(packet.getProgress()))
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.world.level.block.entity.BlockEntityType;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;
import java.util.Objects;

public class BlockEntityDataHandler extends PacketHandler<@NotNull ClientboundBlockEntityDataPacket> {

public BlockEntityDataHandler() {
super(
ClientboundBlockEntityDataPacket.class,
"BlockEntityData",
"Handles ClientboundBlockEntityDataPacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockEntityDataPacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of(
PacketInfoSegment.of(Component.text("Position"), Component.text(packet.getPos().getX() + ", " + packet.getPos().getY() + ", " + packet.getPos().getZ())),
PacketInfoSegment.of(Component.text("Type"), Component.text(Objects.requireNonNullElse(BuiltInRegistries.BLOCK_ENTITY_TYPE.getKey(packet.getType()), "Unknown").toString())),
PacketInfoSegment.of(Component.text("Tag"), Component.text(packet.getTag().toString()))
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.network.protocol.game.ClientboundBlockEventPacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;
import java.util.Objects;

public class BlockEventHandler extends PacketHandler<@NotNull ClientboundBlockEventPacket> {

public BlockEventHandler() {
super(
ClientboundBlockEventPacket.class,
"BlockEvent",
"Handles ClientboundBlockDestructionPacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockEventPacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of(
PacketInfoSegment.of(Component.text("Position"), Component.text(packet.getPos().getX() + ", " + packet.getPos().getY() + ", " + packet.getPos().getZ())),
PacketInfoSegment.of(Component.text("Friction"), Component.text(packet.getBlock().getFriction())),
PacketInfoSegment.of(Component.text("ExplosionResistance"), Component.text(packet.getBlock().getExplosionResistance())),
PacketInfoSegment.of(Component.text("JumpFactor"), Component.text(packet.getBlock().getJumpFactor())),
PacketInfoSegment.of(Component.text("SpeedFactor"), Component.text(packet.getBlock().getSpeedFactor())),
PacketInfoSegment.of(Component.text("B0"), Component.text(packet.getB0())),
PacketInfoSegment.of(Component.text("B1"), Component.text(packet.getB1()))
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundBlockEventPacket;
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;

public class BlockUpdateHandler extends PacketHandler<@NotNull ClientboundBlockUpdatePacket> {

public BlockUpdateHandler() {
super(
ClientboundBlockUpdatePacket.class,
"BlockUpdate",
"Handles ClientboundBlockUpdatePacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBlockUpdatePacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of(
PacketInfoSegment.of(Component.text("Position"), Component.text(packet.getPos().getX() + ", " + packet.getPos().getY() + ", " + packet.getPos().getZ())),
PacketInfoSegment.of(Component.text("BlockState"), Component.text(packet.getBlockState().toString()))
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
import net.minecraft.network.protocol.game.ClientboundBossEventPacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.format.PacketInfoSegment;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;

public class BossEventHandler extends PacketHandler<@NotNull ClientboundBossEventPacket> {

public BossEventHandler() {
super(
ClientboundBossEventPacket.class,
"BossEvent",
"Handles ClientboundBossEventPacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBossEventPacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of()
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundBundleDelimiterPacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;

public class BundleDelimiterHandler extends PacketHandler<@NotNull ClientboundBundleDelimiterPacket> {

public BundleDelimiterHandler() {
super(
ClientboundBundleDelimiterPacket.class,
"BundleDelimiter",
"Handles ClientboundBundleDelimiterPacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBundleDelimiterPacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of()
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package xyz.bitsquidd.ninja.handler.impl.clientbound;

import net.kyori.adventure.text.Component;
import net.minecraft.network.protocol.game.ClientboundBundleDelimiterPacket;
import net.minecraft.network.protocol.game.ClientboundBundlePacket;
import org.jetbrains.annotations.NotNull;

import xyz.bitsquidd.ninja.format.PacketInfoBundle;
import xyz.bitsquidd.ninja.handler.PacketHandler;
import xyz.bitsquidd.ninja.handler.PacketType;

import java.util.List;

public class BundleHandler extends PacketHandler<@NotNull ClientboundBundlePacket> {

public BundleHandler() {
super(
ClientboundBundlePacket.class,
"Bundle",
"Handles ClientboundBundlePacket.",
PacketType.CLIENTBOUND
);
}

@Override
protected @NotNull PacketInfoBundle getPacketInfoInternal(ClientboundBundlePacket packet) {
return PacketInfoBundle.of(
packetType,
Component.text(friendlyName),
List.of()
);
}

}
Loading