Skip to content

Commit

Permalink
Merge remote-tracking branch 'Laiff/feature/level-maintainer-terminal…
Browse files Browse the repository at this point in the history
…' into dev
  • Loading branch information
Dream-Master committed Oct 20, 2023
2 parents c5d52a0 + db71dbc commit 1643466
Showing 1 changed file with 34 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,36 @@ public void fromBytes(ByteBuf buf) {
+ " : "
+ this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
AELog.info("Parsed content: -> " + this.commands);
if (AEConfig.instance.isFeatureEnabled(AEFeature.DebugLogging)) {
AELog.info(" <- Parsed content: " + this.commands);
}
}
AELog.debug(e);
return;
}
}
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
" <- Received commands " + this.commands.size()
+ " : "
+ this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
}
}

public void toBytes(ByteBuf buf) {
try {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
" <- Sent commands " + this.commands.size()
+ " : "
+ this.commands.stream().map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
if (AEConfig.instance.isFeatureEnabled(AEFeature.DebugLogging)) {
AELog.info(" -> Sent commands: " + this.commands);
}
}

buf.writeByte(statusFlags);
buf.writeInt(commands.size());
for (PacketEntry entry : commands) {
Expand Down Expand Up @@ -151,14 +171,6 @@ public IMessage onMessage(SPacketLevelTerminalUpdate message, MessageContext ctx
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;

if (gs instanceof GuiLevelTerminal levelTerminal) {
if (AEConfig.instance.isFeatureEnabled(AEFeature.PacketLogging)) {
AELog.info(
"Received commands -> " + message.commands.size()
+ " : "
+ message.commands.stream()
.map(packetEntry -> packetEntry.getClass().getSimpleName())
.collect(Collectors.groupingBy(String::new, Collectors.counting())));
}
levelTerminal.postUpdate(message.commands, message.statusFlags);
}

Expand Down Expand Up @@ -437,12 +449,19 @@ protected void write(ByteBuf buf) throws IOException {
buf.writeInt(validIndex);
}
}
try (ByteBufOutputStream stream = new ByteBufOutputStream(buf)) {
ByteBuf tempBuf = Unpooled.directBuffer(256);
try {
try (ByteBufOutputStream stream = new ByteBufOutputStream(tempBuf)) {

NBTTagCompound wrapper = new NBTTagCompound();
NBTTagCompound wrapper = new NBTTagCompound();

wrapper.setTag("data", items);
CompressedStreamTools.writeCompressed(wrapper, stream);
wrapper.setTag("data", items);
CompressedStreamTools.writeCompressed(wrapper, stream);
}
buf.writeInt(tempBuf.readableBytes());
buf.writeBytes(tempBuf);
} finally {
tempBuf.release();
}
} else {
buf.writeByte(flags);
Expand Down Expand Up @@ -472,8 +491,8 @@ protected void read(ByteBuf buf) throws IOException {
this.validIndices[i] = buf.readInt();
}
}

try (ByteBufInputStream stream = new ByteBufInputStream(buf)) {
int payloadSize = buf.readInt();
try (ByteBufInputStream stream = new ByteBufInputStream(buf, payloadSize)) {
this.items = CompressedStreamTools.readCompressed(stream).getTagList("data", NBT.TAG_COMPOUND);
}
}
Expand Down

0 comments on commit 1643466

Please sign in to comment.