Skip to content

Commit

Permalink
Remove nbt reading limit in registry-data packet for pre 1.20.5
Browse files Browse the repository at this point in the history
  • Loading branch information
booky10 committed Sep 17, 2024
1 parent 99acbe4 commit 402ebd7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ else if (nbt instanceof NBTCompound) {

public static NBT readNBTFromBuffer(Object byteBuf, ServerVersion serverVersion) {
NBTLimiter limiter = NBTLimiter.forBuffer(byteBuf);
return readNBTFromBuffer(byteBuf, serverVersion, limiter);
}

public static NBT readNBTFromBuffer(Object byteBuf, ServerVersion serverVersion, NBTLimiter limiter) {
if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_8)) {
try {
final boolean named = serverVersion.isOlderThan(ServerVersion.V_1_20_2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import com.github.retrooper.packetevents.protocol.mapper.MappedEntity;
import com.github.retrooper.packetevents.protocol.nbt.NBT;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import com.github.retrooper.packetevents.protocol.nbt.NBTLimiter;
import com.github.retrooper.packetevents.protocol.nbt.codec.NBTCodec;
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon;
Expand Down Expand Up @@ -613,6 +614,14 @@ public NBT readNBTRaw() {
return NBTCodec.readNBTFromBuffer(buffer, serverVersion);
}

public NBTCompound readUnlimitedNBT() {
return (NBTCompound) this.readUnlimitedNBTRaw();
}

public NBT readUnlimitedNBTRaw() {
return NBTCodec.readNBTFromBuffer(buffer, serverVersion, NBTLimiter.noop());
}

public void writeNBT(NBTCompound nbt) {
this.writeNBTRaw(nbt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public WrapperConfigServerRegistryData(

@Override
public void read() {
if (!this.serverVersion.isNewerThanOrEquals(ServerVersion.V_1_20_5)) {
this.registryData = this.readNBT();
if (this.serverVersion.isOlderThan(ServerVersion.V_1_20_5)) {
this.registryData = this.readUnlimitedNBT();
return;
}
this.registryKey = this.readIdentifier();
Expand All @@ -89,7 +89,7 @@ public void read() {

@Override
public void write() {
if (!this.serverVersion.isNewerThanOrEquals(ServerVersion.V_1_20_5)) {
if (this.serverVersion.isOlderThan(ServerVersion.V_1_20_5)) {
this.writeNBT(this.registryData);
return;
}
Expand Down

0 comments on commit 402ebd7

Please sign in to comment.