модернизания NetStream (extends Input/Output stream)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package mc.core.network.proto_1_12_2.packets;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import mc.core.network.proto_1_12_2.NetInputStream_p340;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@Slf4j
|
||||
public class ByteArrayInputNetStream extends NetInputStream_p340 {
|
||||
private ByteArrayInputStream bais;
|
||||
|
||||
@@ -23,14 +25,16 @@ public class ByteArrayInputNetStream extends NetInputStream_p340 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readBytes(byte[] buffer) {
|
||||
public int readBytes(byte[] buffer, int offset, int length) {
|
||||
try {
|
||||
int read = bais.read(buffer);
|
||||
if (read < buffer.length) {
|
||||
int read = bais.read(buffer, offset, length);
|
||||
if (read < length) {
|
||||
throw new IOException("not enough data");
|
||||
}
|
||||
return read;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("", e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user