Skip to content

Commit

Permalink
debugging packets... 🔪
Browse files Browse the repository at this point in the history
  • Loading branch information
sh0inx committed May 17, 2024
1 parent 457c62a commit 693171b
Showing 1 changed file with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.iridium.iridiumskyblock.IridiumSkyblock;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import java.lang.reflect.Field;
import java.util.List;

public class IridiumPacketAdapter extends PacketAdapter {

Expand Down Expand Up @@ -45,33 +45,61 @@ private void editPacketForHorizon(PacketEvent packetEvent, boolean fallback) {
PacketType packetType = packet.getType();

if (!fallback) {
StructureModifier<Boolean> booleans = packet.getBooleans();

// login
// to get all | StructureModifier<Object> modifier = packet.getModifier();
// BOOLEANS | StructureModifier<Boolean> booleans = packet.getBooleans();
// b - [0] hardcore (false)
// g -
// h -
// i -
// ENTITY | StructureModifier<Entity> entity = packet.getEntityModifier(packetEvent);
// a -
// d -
// e -
// f -
// PLAYER INFO DATA | StructureModifier<List<PlayerInfoData>> playerData = packet.getPlayerInfoDataLists();
// c -

// MISSING
// j -

// Packet Capture
// a=331 // ??? entity type?
// b=false // hardcore mode
// c=[ResourceKey[minecraft:dimension / minecraft:overworld], ResourceKey[minecraft:dimension / minecraft:the_nether], ResourceKey[minecraft:dimension / minecraft:the_end], ResourceKey[minecraft:dimension / minecraft:iridiumskyblock], ResourceKey[minecraft:dimension / minecraft:plugins/iridiumskyblock/regenworlds/iridiumskyblock_regen], ResourceKey[minecraft:dimension / minecraft:iridiumskyblock_nether], ResourceKey[minecraft:dimension / minecraft:plugins/iridiumskyblock/regenworlds/iridiumskyblock_nether_regen], ResourceKey[minecraft:dimension / minecraft:plugins/iridiumskyblock/regenworlds/iridiumskyblock_the_end_regen], ResourceKey[minecraft:dimension / minecraft:iridiumskyblock_the_end]]
// d=20 // probably the amount of health the player has
// e=10
// f=10
// g=false
// h=true
// i=false
// j=CommonPlayerSpawnInfo[dimensionType=ResourceKey[minecraft:dimension_type / minecraft:overworld], dimension=ResourceKey[minecraft:dimension / minecraft:iridiumskyblock], seed=8029251825143012118, gameType=CREATIVE, previousGameType=SURVIVAL, isDebug=false, isFlat=false, lastDeathLocation=Optional[ResourceKey[minecraft:dimension / minecraft:iridiumskyblock] BlockPosition{x=1, y=82, z=2}], portalCooldown=0]

int flatWorldIndex = 0;

if(packetType == PacketType.Play.Server.LOGIN) flatWorldIndex = 4;
if(packetType == PacketType.Play.Server.RESPAWN) flatWorldIndex = 1;

StructureModifier<Object> commonPlayerSpawnInfo = packet.getModifier();

int getCommonPlayerSpawnInfoIndex = 0;
if(packetType == PacketType.Play.Server.LOGIN) getCommonPlayerSpawnInfoIndex = 9;
if(packetType == PacketType.Play.Server.RESPAWN) getCommonPlayerSpawnInfoIndex = 0;

IridiumSkyblock.getInstance().getLogger().info("[DEBUG] =+=+=+=+=+=+=+=+=+=+=+=+=");
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PACKET TYPE: " + packetType);
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PACKET STRUCTURES: " + packet.getStructures());
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PACKET FIELDS: " + packet.getStructures().getFields());
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PACKET BOOLEANS: " + booleans);
for(int i = 0; i < booleans.size(); i++) {
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] MAPPED TO: " + booleans.getField(i).getName());
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] =+=+=+=+=+=+=+=+=+=+=+=+=");
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PACKET OBJECT: " + commonPlayerSpawnInfo);
for(int i = 0; i < commonPlayerSpawnInfo.size(); i++) {
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] MAPPED TO: " + commonPlayerSpawnInfo.getField(i).getName());
}
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PRE-MUTATION VALUES: " + booleans.getValues());
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] TESTED PACKET FIELD: " + booleans.getField(flatWorldIndex).getName());
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] TESTED PACKET VALUE: TRUE");
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] PRE-MUTATION VALUES: " + commonPlayerSpawnInfo.getValues());
IridiumSkyblock.getInstance().getLogger().info("[DEBUG] =+=+=+=+=+=+=+=+=+=+=+=+=");

booleans.write(flatWorldIndex, true);
//booleans.write(flatWorldIndex, true);

} else {

Expand Down

0 comments on commit 693171b

Please sign in to comment.