Temporary fix for serverside JEI and valueconfig packets.
It's not pretty but should do until we rewrite the packet/network handler.
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
package appeng.core.sync;
|
package appeng.core.sync;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@@ -93,6 +94,29 @@ public abstract class AppEngPacket implements Packet
|
|||||||
throw new RuntimeException( "Not Implemented" );
|
throw new RuntimeException( "Not Implemented" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Figure out why Forge/Minecraft on the server sets the stream data buffer to PooledUnsafeDirectByteBuf
|
||||||
|
|
||||||
|
public ByteArrayInputStream getPacketByteArray ( ByteBuf stream, int readerIndex, int readableBytes )
|
||||||
|
{
|
||||||
|
final ByteArrayInputStream bytes;
|
||||||
|
if( stream.hasArray() )
|
||||||
|
{
|
||||||
|
bytes = new ByteArrayInputStream( stream.array(), readerIndex, readableBytes );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
byte[] data = new byte[stream.capacity()];
|
||||||
|
stream.getBytes( readerIndex, data, 0, readableBytes );
|
||||||
|
bytes = new ByteArrayInputStream( data );
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ByteArrayInputStream getPacketByteArray ( ByteBuf stream )
|
||||||
|
{
|
||||||
|
return getPacketByteArray( stream, 0, stream.readableBytes() );
|
||||||
|
}
|
||||||
|
|
||||||
public void setCallParam( final PacketCallState call )
|
public void setCallParam( final PacketCallState call )
|
||||||
{
|
{
|
||||||
this.caller = call;
|
this.caller = call;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class PacketJEIRecipe extends AppEngPacket
|
|||||||
// automatic.
|
// automatic.
|
||||||
public PacketJEIRecipe( final ByteBuf stream ) throws IOException
|
public PacketJEIRecipe( final ByteBuf stream ) throws IOException
|
||||||
{
|
{
|
||||||
final ByteArrayInputStream bytes = new ByteArrayInputStream( stream.array() );
|
final ByteArrayInputStream bytes = this.getPacketByteArray( stream );
|
||||||
bytes.skip( stream.readerIndex() );
|
bytes.skip( stream.readerIndex() );
|
||||||
final NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
|
final NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
|
||||||
if( comp != null )
|
if( comp != null )
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package appeng.core.sync.packets;
|
package appeng.core.sync.packets;
|
||||||
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
@@ -66,7 +65,7 @@ public class PacketValueConfig extends AppEngPacket
|
|||||||
// automatic.
|
// automatic.
|
||||||
public PacketValueConfig( final ByteBuf stream ) throws IOException
|
public PacketValueConfig( final ByteBuf stream ) throws IOException
|
||||||
{
|
{
|
||||||
final DataInputStream dis = new DataInputStream( new ByteArrayInputStream( stream.array(), stream.readerIndex(), stream.readableBytes() ) );
|
final DataInputStream dis = new DataInputStream( this.getPacketByteArray( stream, stream.readerIndex(), stream.readableBytes() ) );
|
||||||
this.Name = dis.readUTF();
|
this.Name = dis.readUTF();
|
||||||
this.Value = dis.readUTF();
|
this.Value = dis.readUTF();
|
||||||
// dis.close();
|
// dis.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user