Compare commits

...
21 Commits
Author SHA1 Message Date
retrooper d27d8ffd6a packetevents 2.9.2 release 2025-07-17 15:18:28 +02:00
retrooper 7a57012822 Revert "Cleanup gradle configuration mess"
This reverts commit cfb054b8b2.
2025-07-17 14:01:23 +02:00
retrooper 0a10f4d861 Merge pull request #1265 from Luuzzi/2.0
fix spawn position for versions lower than 1.8 & protocol 4 support
2025-07-13 22:52:41 +02:00
retrooper d1a3145483 Merge pull request #1300 from GrimAnticheat/feature/read-list-max-size
Add new readList(Reader<K> reader, int maxSize) function to PacketWrapper
2025-07-13 22:46:25 +02:00
retrooper 08096106f8 patch: UserLoginEvent always fired in PlayerJoinEvent to provide UUID and username (so it's not a breaking change). 2025-07-13 22:41:22 +02:00
Luuzzi a3fbccc454 1.7.5 and lower doesn't have action START_JUMPING_WITH_HORSE 2025-07-13 20:36:10 +03:00
Luuzzi 9ea931d58d resolve #1301 2025-07-13 20:19:39 +03:00
Alexandr 364be4e34d Merge branch 'retrooper:2.0' into 2.0 2025-07-12 19:11:19 +03:00
Axionize b22394c288 Add new readList(Reader<K> reader, int maxSize) function to PacketWrapper 2025-07-12 09:49:19 -04:00
retrooper 208dfbc3f3 Merge pull request #1294 from booky10/fix/gradle-config-mess
Cleanup gradle configuration mess
2025-07-10 09:11:36 +02:00
booky10 cfb054b8b2 Cleanup gradle configuration mess 2025-07-10 04:58:23 +02:00
booky10 f47e6880fd [skip ci] Add fabric production run task 2025-07-10 02:53:39 +02:00
booky10 f55f791f8a [skip ci] Update gradle wrapper to v8.14.3 2025-07-10 02:53:38 +02:00
booky10 ba389ddb57 [skip ci] Fix changelog 2025-07-10 02:53:38 +02:00
booky10 2ce143d466 [skip ci] Increment version to v2.9.2 snapshot 2025-07-10 02:53:38 +02:00
Alexandr b62fc6922c Merge branch 'retrooper:2.0' into 2.0 2025-06-30 06:55:33 +03:00
Luuzzi c6f129cdd3 added setData and getData to WrappedBlockState 2025-06-28 22:49:57 +03:00
Luuzzi 22b28b7b35 1_7_10 -> 1_7_2. Also wrapper fixes 2025-06-26 23:23:17 +03:00
Luuzzi 9e7de426c0 fix incorrect shifts(get, set) in Chunk_v1_7 2025-06-26 13:17:53 +03:00
Luuzzi a5188e5d78 added support for 1.7.2-1.7.5, seems it works fine 🤔 2025-06-26 07:03:53 +03:00
Luuzzi cce0ac2d7b fix spawn position for versions lower than 1.8 2025-06-26 06:27:49 +03:00
52 changed files with 193 additions and 152 deletions

No files matched your search

+28 -70
View File
@@ -1,3 +1,31 @@
!!!!! v2.9.2
# PacketEvents 2.9.2 is out now! 🎉
This is a patch update that fixes issues with UserLoginEvent (which previously contained null user data) and with importing Adventure serializers.
# Brief Announcement 📢⚠️
### We have our very own website: https://packetevents.com
### Documentation: https://docs.packetevents.com
### JavaDocs: https://javadocs.packetevents.com
## What's Changed (Summary)
* Added support for 1.7.2+ Minecraft protocol (useful for proxies)
* Fixed UserLoginEvent. It is now (always) triggered by PlayerJoinEvent to prevent User instances from containing null data.
* Fixed importing Adventure serializers.
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.9.1...v2.9.2
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
## Maven/Gradle Dependency
### **Check out**: https://docs.packetevents.com/getting-started
!!!!! v2.9.1
# PacketEvents 2.9.1 is out now! 🎉
@@ -97,76 +125,6 @@ This update wouldn't be possible without these contributors ❤️: @booky10, @A
## Maven/Gradle Dependency
### **Check out**: https://docs.packetevents.com/getting-started
!!!!! v2.9.0
# PacketEvents 2.9.0 is out now! 🎉
### New update now supports Minecraft version 1.21.6 & 1.21.7. We suggest that you update, as numerous bugs have been fixed.
# Brief Announcement 📢⚠️
### We have our very own website: https://packetevents.com
### Documentation: https://docs.packetevents.com
### JavaDocs: https://javadocs.packetevents.com
## What's Changed? (Summary)
* Added 1.21.6 support
* Added 1.21.7 support
* Bug fixes
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.8.0...v2.9.0
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
## Maven/Gradle Dependency
### **Check out**: https://docs.packetevents.com/getting-started
!!!!! v2.8.0
# PacketEvents 2.8.0 is out now! 🎉
### New update now supports Minecraft version 1.21.5. Please update, as numerous bugs have been fixed.
# Brief Announcement 📢⚠️
### We have our very own website: https://packetevents.com
### Documentation: https://docs.packetevents.com
### JavaDocs: https://javadocs.packetevents.com
## What's Changed? (Summary)
* Added 1.21.5 support
* Various bugs fixed
**View Full Changelog**: https://github.com/retrooper/packetevents/compare/v2.7.0...v2.8.0
## Contributors 🏅
This update wouldn't be possible without these contributors ❤️: @booky10, @Axionize, @Bram1903, @ManInMyVan, @ytnoos,
@AoElite, @HaHaWTH, @divinepablo, @scienziatopazzo, @bridgelol, @MachineBreaker, @Luuzzi, @Beaness, @Rubenicos, @Loyisa
## New Contributors
* @HaHaWTH made their first contribution in https://github.com/retrooper/packetevents/pull/1097
* @divinepablo made their first contribution in https://github.com/retrooper/packetevents/pull/1098
* @scienziatopazzo made their first contribution in https://github.com/retrooper/packetevents/pull/1105
* @bridgelol made their first contribution in https://github.com/retrooper/packetevents/pull/1199
* @Luuzzi made their first contribution in https://github.com/retrooper/packetevents/pull/1197
* @Beaness made their first contribution in https://github.com/retrooper/packetevents/pull/1212
* @Rubenicos made their first contribution in https://github.com/retrooper/packetevents/pull/1162
* @Loyisa made their first contribution in https://github.com/retrooper/packetevents/pull/1220
## If you want to support PacketEvents, consider sponsoring us on [GitHub Sponsors](https://github.com/sponsors/retrooper)
## Maven/Gradle Dependency
### **Check out**: https://docs.packetevents.com/getting-started
!!!!! v2.7.0
@@ -32,7 +32,8 @@ import org.jetbrains.annotations.NotNull;
*/
public enum ServerVersion {
//TODO Rename to MinecraftVersion?
V_1_7_10(5),
V_1_7_2(4), V_1_7_4(4), V_1_7_5(4),
V_1_7_6(5), V_1_7_7(5), V_1_7_8(5), V_1_7_9(5), V_1_7_10(5),
V_1_8(47), V_1_8_3(47), V_1_8_8(47),
V_1_9(107), V_1_9_1(108), V_1_9_2(109), V_1_9_4(110),
//1.10 and 1.10.1 are redundant
@@ -206,7 +206,7 @@ public final class PacketType {
//TODO UPDATE Update packet type mappings (clientbound pt. 1)
private static final VersionMapper CLIENTBOUND_PLAY_VERSION_MAPPER = new VersionMapper(
ClientVersion.V_1_7_10,
ClientVersion.V_1_7_2,
ClientVersion.V_1_8,
ClientVersion.V_1_9,
ClientVersion.V_1_10,
@@ -235,7 +235,7 @@ public final class PacketType {
//TODO UPDATE Update packet type mappings (serverbound pt. 1)
private static final VersionMapper SERVERBOUND_PLAY_VERSION_MAPPER = new VersionMapper(
ClientVersion.V_1_7_10,
ClientVersion.V_1_7_2,
ClientVersion.V_1_8,
ClientVersion.V_1_9,
ClientVersion.V_1_12,
@@ -39,6 +39,7 @@ import java.util.List;
* @since 1.6.9
*/
public enum ClientVersion {
V_1_7_2(4),
V_1_7_10(5),
V_1_8(47),
@@ -111,7 +112,7 @@ public enum ClientVersion {
//TODO UPDATE Add new protocol version field
@Deprecated
LOWER_THAN_SUPPORTED_VERSIONS(V_1_7_10.protocolVersion - 1, true),
LOWER_THAN_SUPPORTED_VERSIONS(V_1_7_2.protocolVersion - 1, true),
//TODO UPDATE Update HIGHER_THAN_SUPPORTED_VERSIONS field
@Deprecated
HIGHER_THAN_SUPPORTED_VERSIONS(V_1_21_7.protocolVersion + 1, true),
@@ -18,11 +18,9 @@
package com.github.retrooper.packetevents.protocol.world.chunk.impl.v1_7;
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.world.chunk.BaseChunk;
import com.github.retrooper.packetevents.protocol.world.chunk.ByteArray3d;
import com.github.retrooper.packetevents.protocol.world.chunk.NibbleArray3d;
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
public class Chunk_v1_7 implements BaseChunk {
private final ByteArray3d blocks;
@@ -45,13 +43,21 @@ public class Chunk_v1_7 implements BaseChunk {
@Override
public int getBlockId(int x, int y, int z) {
return blocks.get(x, y, z) | (extendedBlocks.get(x, y, z) << 12);
int blockId = (blocks.get(x, y, z) & 0xFF) << 4;
blockId |= metadata.get(x, y, z) & 0xF;
if (extendedBlocks != null) {
blockId |= (extendedBlocks.get(x, y, z) & 0xF) << 8;
}
return blockId;
}
@Override
public void set(int x, int y, int z, int combinedID) {
blocks.set(x, y, z, combinedID & 0xFF);
extendedBlocks.set(x, y, z, combinedID >> 12);
blocks.set(x, y, z, (combinedID >> 4) & 0xFF);
metadata.set(x, y, z, combinedID & 0xF);
if (extendedBlocks != null) {
extendedBlocks.set(x, y, z, (combinedID >> 8) & 0xF);
}
}
@Override
@@ -561,6 +561,16 @@ public class WrappedBlockState {
return type;
}
public Object getData(StateValue stateValue) {
return data.get(stateValue);
}
public void setData(StateValue stateValue, Object object) {
checkIfCloneNeeded();
data.put(stateValue, object);
checkIsStillValid();
}
// Begin all block data types
public int getAge() {
return (int) data.get(StateValue.AGE);
@@ -1362,6 +1362,18 @@ public class PacketWrapper<T extends PacketWrapper<T>> {
public <K, C extends Collection<K>> C readCollection(IntFunction<C> function, Reader<K> reader) {
int size = this.readVarInt();
return _readCollection(function, reader, size);
}
public <K, C extends Collection<K>> C readCollection(IntFunction<C> function, Reader<K> reader, int maxSize) {
int size = this.readVarInt();
if (size > maxSize) {
throw new RuntimeException(size + " elements exceeded max size of: " + maxSize);
}
return _readCollection(function, reader, size);
}
private <K, C extends Collection<K>> C _readCollection(IntFunction<C> function, Reader<K> reader, int size) {
Collection<K> collection = function.apply(size);
for (int i = 0; i < size; ++i) {
collection.add(reader.apply(this));
@@ -1380,6 +1392,10 @@ public class PacketWrapper<T extends PacketWrapper<T>> {
return this.readCollection(ArrayList::new, reader);
}
public <K> List<K> readList(Reader<K> reader, int maxSize) {
return this.readCollection(ArrayList::new, reader, maxSize);
}
public <K> void writeList(List<K> list, Writer<K> writer) {
writeVarInt(list.size());
for (K key : list) {
@@ -76,7 +76,7 @@ public class WrapperCommonClientSettings<T extends WrapperCommonClientSettings<T
this.viewDistance = this.readByte();
this.chatVisibility = this.readEnum(ChatVisibility.values());
this.chatColors = this.readBoolean();
if (this.serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
this.ignoredDifficulty = this.readByte();
if (this.readBoolean()) { // show cape
this.skinMask = SkinSection.CAPE.getMask();
@@ -98,7 +98,7 @@ public class WrapperCommonClientSettings<T extends WrapperCommonClientSettings<T
this.writeByte(this.viewDistance);
this.writeEnum(this.chatVisibility);
this.writeBoolean(this.chatColors);
if (this.serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
this.writeByte(this.ignoredDifficulty);
this.writeBoolean(SkinSection.CAPE.isSet(this.skinMask));
} else {
@@ -64,7 +64,7 @@ public class WrapperPlayClientAnimation extends PacketWrapper<WrapperPlayClientA
/**
* Hand used for the animation.
* On {@link ClientVersion#V_1_9}, an off-hand was introduced and specifies which arm has been swung.
* For {@link ClientVersion#V_1_8} and {@link ClientVersion#V_1_7_10} clients only have a main hand.
* For {@link ClientVersion#V_1_8} and {@link ClientVersion#V_1_7_2} clients only have a main hand.
*
* @return Hand
*/
@@ -75,7 +75,7 @@ public class WrapperPlayClientAnimation extends PacketWrapper<WrapperPlayClientA
/**
* Modify the hand used for the animation.
* On {@link ClientVersion#V_1_9}, an off-hand was introduced and specifies which arm has been swung.
* For {@link ClientVersion#V_1_8} and {@link ClientVersion#V_1_7_10} clients only have a main hand.
* For {@link ClientVersion#V_1_8} and {@link ClientVersion#V_1_7_2} clients only have a main hand.
* Modifying the hand on 1.8 and 1.7 clients is redundant.
*
* @param interactionHand Hand used for the animation
@@ -106,7 +106,8 @@ public class WrapperPlayClientEntityAction extends PacketWrapper<WrapperPlayClie
@Override
public int getId(ServerVersion version) {
return version.isNewerThanOrEquals(ServerVersion.V_1_21_6)
? -1 : this.ordinal();
? -1 : version.isOlderThanOrEquals(ServerVersion.V_1_7_10)
? 1 : this.ordinal();
}
},
/**
@@ -117,7 +118,8 @@ public class WrapperPlayClientEntityAction extends PacketWrapper<WrapperPlayClie
@Override
public int getId(ServerVersion version) {
return version.isNewerThanOrEquals(ServerVersion.V_1_21_6)
? -1 : this.ordinal();
? -1 : version.isOlderThanOrEquals(ServerVersion.V_1_7_10)
? 2 : this.ordinal();
}
},
LEAVE_BED {
@@ -126,7 +128,7 @@ public class WrapperPlayClientEntityAction extends PacketWrapper<WrapperPlayClie
if (version.isNewerThanOrEquals(ServerVersion.V_1_21_6)) {
return this.ordinal() - 2;
}
return this.ordinal();
return version.isOlderThanOrEquals(ServerVersion.V_1_7_10) ? 3 : this.ordinal();
}
},
START_SPRINTING {
@@ -135,7 +137,7 @@ public class WrapperPlayClientEntityAction extends PacketWrapper<WrapperPlayClie
if (version.isNewerThanOrEquals(ServerVersion.V_1_21_6)) {
return this.ordinal() - 2;
}
return this.ordinal();
return version.isOlderThanOrEquals(ServerVersion.V_1_7_10) ? 4 : this.ordinal();
}
},
STOP_SPRINTING {
@@ -144,7 +146,7 @@ public class WrapperPlayClientEntityAction extends PacketWrapper<WrapperPlayClie
if (version.isNewerThanOrEquals(ServerVersion.V_1_21_6)) {
return this.ordinal() - 2;
}
return this.ordinal();
return version.isOlderThanOrEquals(ServerVersion.V_1_7_10) ? 5 : this.ordinal();
}
},
START_JUMPING_WITH_HORSE {
@@ -153,7 +155,8 @@ public class WrapperPlayClientEntityAction extends PacketWrapper<WrapperPlayClie
if (version.isNewerThanOrEquals(ServerVersion.V_1_21_6)) {
return this.ordinal() - 2;
}
return this.ordinal();
return version.isOlderThanOrEquals(ServerVersion.V_1_7_10) ?
(version.isOlderThanOrEquals(ServerVersion.V_1_7_5) ? -1 : 6) : this.ordinal();
}
},
/**
@@ -54,7 +54,7 @@ public class WrapperPlayClientInteractEntity extends PacketWrapper<WrapperPlayCl
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
this.entityID = readInt();
byte typeIndex = readByte();
this.interactAction = InteractAction.VALUES[typeIndex];
@@ -91,7 +91,7 @@ public class WrapperPlayClientInteractEntity extends PacketWrapper<WrapperPlayCl
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(entityID);
writeByte(interactAction.ordinal());
} else {
@@ -86,7 +86,7 @@ public class WrapperPlayClientPlayerBlockPlacement extends PacketWrapper<Wrapper
sequence = readVarInt();
}
} else {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
blockPosition = new Vector3i(readInt(), readUnsignedByte(), readInt());
} else {
blockPosition = readBlockPosition();
@@ -127,7 +127,7 @@ public class WrapperPlayClientPlayerBlockPlacement extends PacketWrapper<Wrapper
writeVarInt(sequence);
}
} else {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(blockPosition.x);
writeByte(blockPosition.y);
writeInt(blockPosition.z);
@@ -72,7 +72,7 @@ public class WrapperPlayClientPlayerFlying extends PacketWrapper<WrapperPlayClie
if (positionChanged) {
double x = readDouble();
double y = readDouble();
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
//Can be ignored, cause stance = (y + 1.62)
double stance = readDouble();
}
@@ -93,7 +93,7 @@ public class WrapperPlayClientPlayerFlying extends PacketWrapper<WrapperPlayClie
public void write() {
if (positionChanged) {
writeDouble(location.getPosition().getX());
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
//Can be ignored, cause stance = (y + 1.62)
writeDouble(location.getPosition().getY() + 1.62);
}
@@ -58,7 +58,7 @@ public class WrapperPlayClientPluginMessage extends PacketWrapper<WrapperPlayCli
this.channelName = readString(20);
}
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
//It is ignored, because we don't need it
int legacyDataSize = readShort();
}
@@ -75,7 +75,7 @@ public class WrapperPlayClientPluginMessage extends PacketWrapper<WrapperPlayCli
else {
writeString(this.channelName, 20);
}
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeShort(this.data.length);
}
writeBytes(this.data);
@@ -45,7 +45,7 @@ public class WrapperPlayServerBlockAction extends PacketWrapper<WrapperPlayServe
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
int x = readInt();
int y = readShort();
int z = readInt();
@@ -60,7 +60,7 @@ public class WrapperPlayServerBlockAction extends PacketWrapper<WrapperPlayServe
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(blockPosition.x);
writeShort(blockPosition.y);
writeInt(blockPosition.z);
@@ -43,7 +43,7 @@ public class WrapperPlayServerBlockBreakAnimation extends PacketWrapper<WrapperP
@Override
public void read() {
entityID = readVarInt();
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
int x = readInt();
int y = readInt();
int z = readInt();
@@ -57,7 +57,7 @@ public class WrapperPlayServerBlockBreakAnimation extends PacketWrapper<WrapperP
@Override
public void write() {
writeVarInt(entityID);
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(blockPosition.x);
writeInt(blockPosition.y);
writeInt(blockPosition.z);
@@ -41,7 +41,7 @@ public class WrapperPlayServerBlockChange extends PacketWrapper<WrapperPlayServe
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
blockPosition = new Vector3i(readInt(), readUnsignedByte(), readInt());
int block = readVarInt();
int blockData = readUnsignedByte();
@@ -54,7 +54,7 @@ public class WrapperPlayServerBlockChange extends PacketWrapper<WrapperPlayServe
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(blockPosition.getX());
writeByte(blockPosition.getY());
writeInt(blockPosition.getZ());
@@ -41,7 +41,7 @@ public class WrapperPlayServerCollectItem extends PacketWrapper<WrapperPlayServe
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
collectedEntityId = readInt();
collectorEntityId = readInt();
} else {
@@ -55,7 +55,7 @@ public class WrapperPlayServerCollectItem extends PacketWrapper<WrapperPlayServe
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(collectedEntityId);
writeInt(collectorEntityId);
} else {
@@ -45,7 +45,7 @@ public class WrapperPlayServerDestroyEntities extends PacketWrapper<WrapperPlayS
if (serverVersion == ServerVersion.V_1_17) {
entityIDs = new int[]{readVarInt()};
} else {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
int entityIDCount = readUnsignedByte();
entityIDs = new int[entityIDCount];
for (int i = 0; i < entityIDCount; i++) {
@@ -66,7 +66,7 @@ public class WrapperPlayServerDestroyEntities extends PacketWrapper<WrapperPlayS
if (serverVersion == ServerVersion.V_1_17) {
writeVarInt(entityIDs[0]);
} else {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeByte(entityIDs.length);
for (int entityID : entityIDs) {
writeInt(entityID);
@@ -45,7 +45,7 @@ public class WrapperPlayServerEntityEquipment extends PacketWrapper<WrapperPlayS
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
entityId = readInt();
} else {
entityId = readVarInt();
@@ -72,7 +72,7 @@ public class WrapperPlayServerEntityEquipment extends PacketWrapper<WrapperPlayS
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(entityId);
} else {
writeVarInt(entityId);
@@ -49,7 +49,7 @@ public class WrapperPlayServerEntityVelocity extends PacketWrapper<WrapperPlaySe
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
entityID = readInt();
} else {
entityID = readVarInt();
@@ -62,7 +62,7 @@ public class WrapperPlayServerEntityVelocity extends PacketWrapper<WrapperPlaySe
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(entityID);
} else {
writeVarInt(entityID);
@@ -77,7 +77,7 @@ public class WrapperPlayServerParticle extends PacketWrapper<WrapperPlayServerPa
int particleTypeId = 0;
ParticleType<?> particleType = null;
boolean v1205 = this.serverVersion.isNewerThanOrEquals(ServerVersion.V_1_20_5);
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
String particleName = readString(64);
particleType = ParticleTypes.getByName("minecraft:" + particleName);
} else if (!v1205) {
@@ -118,7 +118,7 @@ public class WrapperPlayServerParticle extends PacketWrapper<WrapperPlayServerPa
@Override
public void write() {
//TODO on 1.7 we get particle type by 64 len string
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeString(particle.getType().getName().getKey(), 64);
} else if (this.serverVersion.isOlderThan(ServerVersion.V_1_20_5)) {
int id = this.particle.getType().getId(this.serverVersion.toClientVersion());
@@ -71,7 +71,7 @@ public class WrapperPlayServerPlayerInfo extends PacketWrapper<WrapperPlayServer
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
playerDataList = new ArrayList<>(1);
//Only one player data
String rawUsername = readString();
@@ -145,7 +145,7 @@ public class WrapperPlayServerPlayerInfo extends PacketWrapper<WrapperPlayServer
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
//Only one player data can be sent
PlayerData data = playerDataList.get(0);
//We must convert the component string to a normal one
@@ -58,7 +58,7 @@ public class WrapperPlayServerPluginMessage extends PacketWrapper<WrapperPlaySer
else {
this.channelName = readString(20);
}
if (serverVersion == ServerVersion.V_1_7_10) {
if (serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
//We ignore this, because it's not needed.
int legacyDataSize = readShort();
}
@@ -73,7 +73,7 @@ public class WrapperPlayServerPluginMessage extends PacketWrapper<WrapperPlaySer
else {
writeString(this.channelName, 20);
}
if (serverVersion == ServerVersion.V_1_7_10) {
if (serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeShort(data.length);
}
writeBytes(data);
@@ -42,7 +42,7 @@ public class WrapperPlayServerSetExperience extends PacketWrapper<WrapperPlaySer
@Override
public void read() {
experienceBar = readFloat();
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
level = readShort();
totalExperience = readShort();
} else {
@@ -54,7 +54,7 @@ public class WrapperPlayServerSetExperience extends PacketWrapper<WrapperPlaySer
@Override
public void write() {
writeFloat(experienceBar);
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeShort(level);
writeShort(totalExperience);
} else {
@@ -51,7 +51,7 @@ public class WrapperPlayServerSpawnPosition extends PacketWrapper<WrapperPlaySer
this.position = new Vector3i(readLong(), this.serverVersion);
} else {
int x = readInt();
int y = readShort();
int y = readInt();
int z = readInt();
this.position = new Vector3i(x, y, z);
}
@@ -67,7 +67,7 @@ public class WrapperPlayServerSpawnPosition extends PacketWrapper<WrapperPlaySer
writeLong(positionVector);
} else {
writeInt(this.position.x);
writeShort(this.position.y);
writeInt(this.position.y);
writeInt(this.position.z);
}
if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_17)) {
@@ -179,7 +179,7 @@ public class WrapperPlayServerTeams extends PacketWrapper<WrapperPlayServerTeams
prefix = serializer.deserialize(this.readString(16));
suffix = serializer.deserialize(this.readString(16));
optionData = OptionData.values()[readByte()];
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
nameTagVisibility = NameTagVisibility.ALWAYS;
color = NamedTextColor.WHITE;
} else {
@@ -217,7 +217,7 @@ public class WrapperPlayServerTeams extends PacketWrapper<WrapperPlayServerTeams
players = new ArrayList<>();
if (teamMode == TeamMode.CREATE || teamMode == TeamMode.ADD_ENTITIES || teamMode == TeamMode.REMOVE_ENTITIES) {
int size;
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
size = readShort();
} else {
size = readVarInt();
@@ -241,7 +241,7 @@ public class WrapperPlayServerTeams extends PacketWrapper<WrapperPlayServerTeams
writeString(LegacyFormat.trimLegacyFormat(serializer.serialize(info.prefix), 16));
writeString(LegacyFormat.trimLegacyFormat(serializer.serialize(info.suffix), 16));
writeByte(info.optionData.ordinal());
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeString(NameTagVisibility.ALWAYS.getId(), 32);
writeByte(15);
} else {
@@ -274,7 +274,7 @@ public class WrapperPlayServerTeams extends PacketWrapper<WrapperPlayServerTeams
}
if (teamMode == TeamMode.CREATE || teamMode == TeamMode.ADD_ENTITIES || teamMode == TeamMode.REMOVE_ENTITIES) {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeShort(players.size());
} else {
writeVarInt(players.size());
@@ -83,7 +83,7 @@ public class WrapperPlayServerUpdateAttributes extends PacketWrapper<WrapperPlay
@Override
public void read() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
entityID = readInt();
} else {
entityID = readVarInt();
@@ -116,7 +116,7 @@ public class WrapperPlayServerUpdateAttributes extends PacketWrapper<WrapperPlay
double value = readDouble();
int modifiersLength;
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
modifiersLength = readShort();
} else {
modifiersLength = readVarInt();
@@ -144,7 +144,7 @@ public class WrapperPlayServerUpdateAttributes extends PacketWrapper<WrapperPlay
@Override
public void write() {
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeInt(entityID);
} else {
writeVarInt(entityID);
@@ -167,7 +167,7 @@ public class WrapperPlayServerUpdateAttributes extends PacketWrapper<WrapperPlay
}
writeDouble(property.value);
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeShort(property.modifiers.size());
} else {
writeVarInt(property.modifiers.size());
@@ -42,7 +42,7 @@ public class WrapperPlayServerUpdateHealth extends PacketWrapper<WrapperPlayServ
@Override
public void read() {
health = readFloat();
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
food = readShort();
} else {
food = readVarInt();
@@ -53,7 +53,7 @@ public class WrapperPlayServerUpdateHealth extends PacketWrapper<WrapperPlayServ
@Override
public void write() {
writeFloat(health);
if (serverVersion == ServerVersion.V_1_7_10) {
if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeShort(food);
} else {
writeVarInt(food);
@@ -68,7 +68,7 @@ public class WrapperPlayServerUpdateScore extends PacketWrapper<WrapperPlayServe
this.value = Optional.of(this.readVarInt());
this.entityDisplayName = this.readOptional(PacketWrapper::readComponent);
this.scoreFormat = this.readOptional(ScoreFormat::readTyped);
} else if (this.serverVersion == ServerVersion.V_1_7_10) {
} else if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
entityName = readString(16);
action = Action.VALUES[readByte()];
if (action != Action.REMOVE_ITEM) {
@@ -107,7 +107,7 @@ public class WrapperPlayServerUpdateScore extends PacketWrapper<WrapperPlayServe
this.writeVarInt(this.value.orElse(0));
this.writeOptional(this.entityDisplayName, PacketWrapper::writeComponent);
this.writeOptional(this.scoreFormat, ScoreFormat::writeTyped);
} else if (this.serverVersion == ServerVersion.V_1_7_10) {
} else if (this.serverVersion.isOlderThanOrEquals(ServerVersion.V_1_7_10)) {
writeString(entityName, 16);
writeByte(action.ordinal());
if (action != Action.REMOVE_ITEM) {
+1 -1
View File
@@ -18,7 +18,7 @@ version = "${ext["fullVersion"]}${ext[if (ext["snapshot"] == true) "versionMetaW
tasks {
wrapper {
gradleVersion = "8.13"
gradleVersion = "8.14.3"
distributionType = Wrapper.DistributionType.ALL
}
+7
View File
@@ -2,6 +2,7 @@ import me.modmuss50.mpp.ModPublishExtension
import me.modmuss50.mpp.PublishModTask
import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RemapSourcesJarTask
import net.fabricmc.loom.task.prod.ServerProductionRunTask
plugins {
packetevents.`library-conventions`
@@ -82,3 +83,9 @@ configure<ModPublishExtension> {
file = tasks.named<RemapJarTask>("remapJar").flatMap { it.archiveFile }
additionalFiles.from(tasks.named<RemapSourcesJarTask>("remapSourcesJar").flatMap { it.archiveFile })
}
tasks.register<ServerProductionRunTask>("prodServer") {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(21)
}
}
+1 -1
View File
@@ -4,7 +4,7 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.6
minecraft_version=1.21.7
parchment_mappings=2025.06.01
parchment_minecraft_version=1.21.5
loader_version=0.16.14
+1 -1
View File
@@ -1,7 +1,7 @@
org.gradle.jvmargs=-Xmx2000m
# TODO UPDATE
fullVersion=2.9.1
fullVersion=2.9.2
snapshot=false
publishing.display_name=PacketEvents
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -2
View File
@@ -114,7 +114,7 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
CLASSPATH="\\\"\\\""
# Determine the Java command to use to start the JVM.
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
Vendored
+2 -2
View File
@@ -70,11 +70,11 @@ goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
set CLASSPATH=
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
:end
@rem End local scope for the variables with windows NT shell
+1 -1
View File
@@ -10,7 +10,7 @@ paper = "1.20.6-R0.1-SNAPSHOT"
bungeecord = "1.21-R0.1-SNAPSHOT"
velocity = "3.4.0-SNAPSHOT"
run-paper = "2.3.1"
fabric-loom = "1.10.5"
fabric-loom = "1.11.4"
spongeGradle = "2.2.0"
classgraph = "4.8.179"
+1 -1
View File
@@ -16405,7 +16405,7 @@
"bubble_column",
"structure_block"
],
"V_1_7_10": [
"V_1_7_2": [
"air",
"stone",
"grass_block",
+1 -1
View File
@@ -32,7 +32,7 @@
"suggest_command",
"change_page"
],
"V_1_7_10": [
"V_1_7_2": [
"open_url",
"open_file",
"run_command",
+1 -1
View File
@@ -11,7 +11,7 @@
"the_nether": 2,
"the_end": 3
},
"V_1_7_10": {
"V_1_7_2": {
"overworld": 0,
"the_nether": -1,
"the_end": 1
+1 -1
View File
@@ -54,7 +54,7 @@
"diamond",
"turtle_scute"
],
"V_1_7_10": [
"V_1_7_2": [
"leather",
"chainmail",
"iron",
+1 -1
View File
@@ -1,5 +1,5 @@
{
"V_1_7_10": [
"V_1_7_2": [
"white",
"creamy",
"chestnut",
+1 -1
View File
@@ -205,7 +205,7 @@
"luck": 26,
"unluck": 27
},
"V_1_7_10": {
"V_1_7_2": {
"speed": 1,
"slowness": 2,
"haste": 3,
+1 -1
View File
@@ -1,5 +1,5 @@
{
"V_1_7_10": [
"V_1_7_2": [
"red"
],
"V_1_14": [
+1 -1
View File
@@ -136,7 +136,7 @@
"fire",
"donkey_kong"
],
"V_1_7_10": [
"V_1_7_2": [
"kebab",
"aztec",
"alban",
@@ -0,0 +1,36 @@
/*
* This file is part of packetevents - https://github.com/retrooper/packetevents
* Copyright (C) 2025 retrooper and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.github.retrooper.packetevents.bukkit;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.PacketEventsAPI;
import com.github.retrooper.packetevents.event.UserLoginEvent;
import com.github.retrooper.packetevents.protocol.player.User;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class InternalGlobalBukkitListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
PacketEventsAPI<?> api = PacketEvents.getAPI();
User user = api.getPlayerManager().getUser(event.getPlayer());
PacketEvents.getAPI().getEventManager().callEvent(new UserLoginEvent(user, event.getPlayer()));
}
}
@@ -34,6 +34,7 @@ import com.github.retrooper.packetevents.util.LogManager;
import com.github.retrooper.packetevents.util.PEVersion;
import io.github.retrooper.packetevents.bukkit.InternalBukkitListener;
import io.github.retrooper.packetevents.bukkit.InternalBukkitLoginListener;
import io.github.retrooper.packetevents.bukkit.InternalGlobalBukkitListener;
import io.github.retrooper.packetevents.bukkit.InternalPaperListener;
import io.github.retrooper.packetevents.injector.SpigotChannelInjector;
import io.github.retrooper.packetevents.injector.connection.ServerConnectionInitializer;
@@ -162,6 +163,8 @@ public class SpigotPacketEventsBuilder {
//Just to have an idea of which versions of packetevents people use
metrics.addCustomChart(new SimplePie("packetevents_version", () -> getVersion().toStringWithoutSnapshot()));
Bukkit.getPluginManager().registerEvents(new InternalGlobalBukkitListener(), plugin);
try {
// register paper listener to support 1.21.7+ configuration api
Class.forName("io.papermc.paper.connection.PlayerConnection");
@@ -47,7 +47,6 @@ public class SpigotChannelInjector implements ChannelInjector {
private int connectionChannelsListIndex = -1;
public void updatePlayer(User user, Object player) {
PacketEvents.getAPI().getEventManager().callEvent(new UserLoginEvent(user, player));
Object channel = user.getChannel();
if (channel == null) {
channel = PacketEvents.getAPI().getPlayerManager().getChannel(player);
@@ -18,6 +18,7 @@
package io.github.retrooper.packetevents.sponge;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.event.UserLoginEvent;
import com.github.retrooper.packetevents.protocol.player.User;
import com.github.retrooper.packetevents.util.FakeChannelUtil;
import io.github.retrooper.packetevents.sponge.injector.SpongeChannelInjector;
@@ -49,6 +50,7 @@ public class InternalSpongeListener {
}
// Set player object in the injectors
PacketEvents.getAPI().getEventManager().callEvent(new UserLoginEvent(user, player));
injector.updatePlayer(user, player);
}
@@ -50,7 +50,6 @@ public class SpongeChannelInjector implements ChannelInjector {
private int connectionChannelsListIndex = -1;
public void updatePlayer(User user, Object player) {
PacketEvents.getAPI().getEventManager().callEvent(new UserLoginEvent(user, player));
Object channel = user.getChannel();
if (channel == null) {
channel = PacketEvents.getAPI().getPlayerManager().getChannel(player);