Skip to content

Commit

Permalink
1.21.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Leymooo committed Nov 23, 2024
1 parent b636564 commit c320a36
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 72 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ manifest.mf
# delombok
*/src/main/lombok

fonts/
fonts/
BotFilter/
config.yml
proxy.log.*
42 changes: 28 additions & 14 deletions protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x24 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x28 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x29 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x2B )
map( ProtocolConstants.MINECRAFT_1_20_5, 0x2B ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x2C )
);
TO_CLIENT.registerPacket(
TimeUpdate.class, TimeUpdate::new,
Expand All @@ -883,7 +884,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x5E ),
map( ProtocolConstants.MINECRAFT_1_20_2,0x60),
map( ProtocolConstants.MINECRAFT_1_20_3,0x62),
map( ProtocolConstants.MINECRAFT_1_20_5,0x64)
map( ProtocolConstants.MINECRAFT_1_20_5,0x64),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x6B )
);
TO_CLIENT.registerPacket(
PlayerPositionAndLook.class, PlayerPositionAndLook::new,
Expand All @@ -901,7 +903,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x38 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x3C ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3E),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x40)
map( ProtocolConstants.MINECRAFT_1_20_5, 0x40),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x42 )
);
TO_CLIENT.registerPacket(
//todo
Expand All @@ -919,7 +922,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x20 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x24 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x25),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x27)
map( ProtocolConstants.MINECRAFT_1_20_5, 0x27),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x28 )
);
TO_CLIENT.registerPacket(
SetSlot.class, SetSlot::new,
Expand Down Expand Up @@ -952,7 +956,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x30 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x34 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x36),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x38)
map( ProtocolConstants.MINECRAFT_1_20_5, 0x38),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x3A )
);
TO_CLIENT.registerPacket(
SetExp.class, SetExp::new,
Expand All @@ -969,7 +974,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x56 ),
map( ProtocolConstants.MINECRAFT_1_20_2,0x58),
map( ProtocolConstants.MINECRAFT_1_20_3,0x5A),
map( ProtocolConstants.MINECRAFT_1_20_5,0x5C)
map( ProtocolConstants.MINECRAFT_1_20_5,0x5C),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x61 )
);
TO_CLIENT.registerPacket(
DefaultSpawnPosition.class, DefaultSpawnPosition::new,
Expand All @@ -988,7 +994,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x50 ),
map( ProtocolConstants.MINECRAFT_1_20_2,0x52),
map( ProtocolConstants.MINECRAFT_1_20_3,0x54),
map( ProtocolConstants.MINECRAFT_1_20_5,0x56)
map( ProtocolConstants.MINECRAFT_1_20_5,0x56),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x5B )
);
TO_SERVER.registerPacket(
ClientSettings.class, ClientSettings::new,
Expand All @@ -1002,7 +1009,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A )
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x0C )
);
TO_SERVER.registerPacket(
TeleportConfirm.class, TeleportConfirm::new,
Expand All @@ -1024,7 +1032,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x15 ),
map( ProtocolConstants.MINECRAFT_1_20_2,0x17),
map( ProtocolConstants.MINECRAFT_1_20_3,0x18),
map( ProtocolConstants.MINECRAFT_1_20_5,0x1B)
map( ProtocolConstants.MINECRAFT_1_20_5,0x1B),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x1D )
);
TO_SERVER.registerPacket(
PlayerPosition.class, PlayerPosition::new,
Expand All @@ -1042,7 +1051,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x14 ),
map( ProtocolConstants.MINECRAFT_1_20_2,0x16),
map( ProtocolConstants.MINECRAFT_1_20_3,0x17),
map( ProtocolConstants.MINECRAFT_1_20_5,0x1A)
map( ProtocolConstants.MINECRAFT_1_20_5,0x1A),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x1C )
);
TO_SERVER.registerPacket(
Player.class, Player::new,
Expand All @@ -1060,7 +1070,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x17 ),
map( ProtocolConstants.MINECRAFT_1_20_2,0x19),
map( ProtocolConstants.MINECRAFT_1_20_3,0x1A),
map( ProtocolConstants.MINECRAFT_1_20_5,0x1D)
map( ProtocolConstants.MINECRAFT_1_20_5,0x1D),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x1F )
);
TO_SERVER.registerPacket(
KeepAlive.class, KeepAlive::new,
Expand All @@ -1078,7 +1089,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x18 )
map( ProtocolConstants.MINECRAFT_1_20_5, 0x18 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x1A )
);
TO_SERVER.registerPacket(
Chat.class, Chat::new,
Expand All @@ -1094,7 +1106,8 @@ public enum Protocol
ClientChat::new,
map( ProtocolConstants.MINECRAFT_1_19, 0x04 ),
map( ProtocolConstants.MINECRAFT_1_19_1, 0x05 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x06 )
map( ProtocolConstants.MINECRAFT_1_20_5, 0x06 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x07 )
);
TO_SERVER.registerPacket(
PluginMessage.class, PluginMessage::new,
Expand All @@ -1111,7 +1124,8 @@ public enum Protocol
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ),
map( ProtocolConstants.MINECRAFT_1_20_5, 0x12 )
map( ProtocolConstants.MINECRAFT_1_20_5, 0x12 ),
map( ProtocolConstants.MINECRAFT_1_21_2, 0x14 )
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
writeVarInt( 0, buf ); //portal cooldown
}

if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
writeVarInt( 60, buf ); //sea level
}

if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
{
buf.writeBoolean( false ); //secure profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ public class Player extends DefinedPacket
@Override
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
this.onGround = buf.readBoolean();
if (protocolVersion < ProtocolConstants.MINECRAFT_1_21_2)
{
this.onGround = buf.readBoolean();
} else {
short flags = buf.readUnsignedByte();
this.onGround = (flags & 1) != 0;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
this.x = buf.readDouble();
this.y = buf.readDouble();
this.z = buf.readDouble();
this.onGround = buf.readBoolean();
if (protocolVersion < ProtocolConstants.MINECRAFT_1_21_2)
{
this.onGround = buf.readBoolean();
} else {
short flags = buf.readUnsignedByte();
this.onGround = (flags & 1) != 0;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,38 @@ public class PlayerPositionAndLook extends DefinedPacket
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
buf.writeDouble( this.x );
buf.writeDouble( this.y );
buf.writeDouble( this.z );
buf.writeFloat( this.yaw );
buf.writeFloat( this.pitch );
buf.writeByte( 0x00 );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )

if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
PlayerPositionAndLook.writeVarInt( teleportId, buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 && protocolVersion <= ProtocolConstants.MINECRAFT_1_19_3 )
DefinedPacket.writeVarInt( teleportId, buf );
buf.writeDouble( this.x );
buf.writeDouble( this.y );
buf.writeDouble( this.z );
buf.writeDouble( 0 ); //velocity x
buf.writeDouble( 0 ); //velocity y
buf.writeDouble( 0 ); //velocity z
buf.writeFloat( this.yaw );
buf.writeFloat( this.pitch );
buf.writeInt( 0 );//teleport flags
} else
{
buf.writeBoolean( true ); // Dismount Vehicle
buf.writeDouble( this.x );
buf.writeDouble( this.y );
buf.writeDouble( this.z );
buf.writeFloat( this.yaw );
buf.writeFloat( this.pitch );
buf.writeByte( 0x00 );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_9 )
{
PlayerPositionAndLook.writeVarInt( teleportId, buf );
}
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_17 && protocolVersion <= ProtocolConstants.MINECRAFT_1_19_3 )
{
buf.writeBoolean( true ); // Dismount Vehicle
}
}


}

@Override
Expand All @@ -54,7 +72,13 @@ public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protoco
this.z = buf.readDouble();
this.yaw = buf.readFloat();
this.pitch = buf.readFloat();
this.onGround = buf.readBoolean();
if (protocolVersion < ProtocolConstants.MINECRAFT_1_21_2)
{
this.onGround = buf.readBoolean();
} else {
short flags = buf.readUnsignedByte();
this.onGround = (flags & 1) != 0;
}
}

@Override
Expand Down
26 changes: 19 additions & 7 deletions protocol/src/main/java/ru/leymooo/botfilter/packets/SetSlot.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ public class SetSlot extends DefinedPacket
@Override
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int version)
{
buf.writeByte( this.windowId );

if ( version >= ProtocolConstants.MINECRAFT_1_21_2 )
{
DefinedPacket.writeVarInt( this.windowId, buf );
} else
{
buf.writeByte( this.windowId );
}
if ( version >= ProtocolConstants.MINECRAFT_1_17_1 )
{
DefinedPacket.writeVarInt( 0, buf );
Expand Down Expand Up @@ -96,11 +101,18 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int versio
{
if ( isMap )
{
DefinedPacket.writeVarInt( 1, buf );
DefinedPacket.writeVarInt( 0, buf );

DefinedPacket.writeVarInt( 26, buf );
DefinedPacket.writeVarInt( 0, buf );
DefinedPacket.writeVarInt( 1, buf ); //added components
DefinedPacket.writeVarInt( 0, buf ); //removed components

if ( version < ProtocolConstants.MINECRAFT_1_21_2 )
{
DefinedPacket.writeVarInt( 26, buf ); //map data component
} else
{
DefinedPacket.writeVarInt( 36, buf ); //map data component

}
DefinedPacket.writeVarInt( 0, buf ); //component value


} else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protoc
{
buf.writeLong( age );
buf.writeLong( time );
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_21_2 )
{
buf.writeBoolean( false ); //time of day increasing
}
}

@Override
Expand Down
Loading

0 comments on commit c320a36

Please sign in to comment.