2014-02-16 05:33:13 +01:00
|
|
|
package appeng.core.sync.packets;
|
|
|
|
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.inventory.Container;
|
|
|
|
import appeng.container.AEBaseContainer;
|
|
|
|
import appeng.core.sync.AppEngPacket;
|
|
|
|
import appeng.core.sync.network.INetworkInfo;
|
|
|
|
|
|
|
|
public class PacketProgressBar extends AppEngPacket
|
|
|
|
{
|
|
|
|
|
|
|
|
short id;
|
2014-02-16 08:33:17 +01:00
|
|
|
long value;
|
2014-02-16 05:33:13 +01:00
|
|
|
|
|
|
|
// automatic.
|
|
|
|
public PacketProgressBar(ByteBuf stream) throws IOException {
|
|
|
|
id = stream.readShort();
|
2014-02-16 08:33:17 +01:00
|
|
|
value = stream.readLong();
|
2014-02-16 05:33:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
|
|
|
{
|
|
|
|
Container c = player.openContainer;
|
|
|
|
if ( c instanceof AEBaseContainer )
|
2014-02-16 08:33:17 +01:00
|
|
|
((AEBaseContainer) c).updateFullProgressBar( id, value );
|
2014-02-16 05:33:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
|
|
|
{
|
|
|
|
Container c = player.openContainer;
|
|
|
|
if ( c instanceof AEBaseContainer )
|
2014-02-16 08:33:17 +01:00
|
|
|
((AEBaseContainer) c).updateFullProgressBar( id, value );
|
2014-02-16 05:33:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// api
|
2014-02-16 08:33:17 +01:00
|
|
|
public PacketProgressBar(int short_id, long value) throws IOException {
|
2014-02-16 05:33:13 +01:00
|
|
|
|
|
|
|
this.id = (short) short_id;
|
|
|
|
this.value = value;
|
|
|
|
|
|
|
|
ByteBuf data = Unpooled.buffer();
|
|
|
|
|
|
|
|
data.writeInt( getPacketID() );
|
|
|
|
data.writeShort( short_id );
|
2014-02-16 08:33:17 +01:00
|
|
|
data.writeLong( value );
|
2014-02-16 05:33:13 +01:00
|
|
|
|
|
|
|
configureWrite( data );
|
|
|
|
}
|
|
|
|
}
|